admin管理员组

文章数量:1647984

1、写一个名为 Account 的类模拟账户。该类的属性和方法如下图所示。该类包括的属性:
账号 id,余额 balance,年利率 annualInterestRate;包含的方法:访问器方法(getter 和
setter 方法),返回月利率的方法 getMonthlyInterest(),取款方法 withdraw(),存款方法
deposit()。

写一个用户程序测试 Account 类。在用户程序中,创建一个账号为 1122、余额为 20000、
年利率 4.5%的 Account 对象。使用 withdraw 方法提款 30000 元,并打印余额。
再使用 withdraw 方法提款 2500 元,使用 deposit 方法存款 3000 元,然后打印余额和月利
率。

package com.atguigu.exer2;
/*
 * 写一个用户程序测试Account类。在用户程序中,
 * 创建一个账号为1122、余额为20000、年利率4.5%的Account对象。
 * 使用withdraw方法提款30000元,并打印余额。
 * 再使用withdraw方法提款2500元,
 * 使用deposit方法存款3000元,然后打印余额和月利率。

 * 
 */
public class AccountTest {
   
	public static void main(String[] args) {
   
		
		Account acct = new Account(1122, 20000, 0.045);
		
		acct.withdraw(30000);
		System.out.println(

本文标签: 账户JavaAccountSuper