Java编程:建立一个银行账户类BankAccount

来源:百度知道 编辑:UC知道 时间:2024/05/29 05:00:21
该类数据成员包括:(1)户名m_iName(2)账户金额m_dBalance(3)年利率m_dInterestRate
该类的成员函数包括:(1)构造函数BankAccount,设置户名、账户金额、利率的初始值,构造函数重载;(2)函数getBalance,获取账户金额;(3)函数getInterestRate,获取当前利率;(4)函数setInterestRate,设置当前利率;(5)函数printAccountMsg,打印当前账户信息;(6)函数saveMoney,存款操作;(7)函数getMoney,取款操作;(8)函数caculateInterest(int Days)按当前利率当前存款计算给定天数的净利息。
建应用程序类ExampleAccount,在应用函数类的main函数中完成以下操作(1)建一个BankAccount类的对象;(2)打印账户信息;(3)存入一笔钱;(4)打印账户信息;(5)取出一笔钱;(6)打印账户信息;(7)计算十年后的银行存款额并打印;(8)改变利率后计算十年后的银行存款额并打印。

public class BankAccount {
private String m_iName;
private double m_dBalance;
private double m_dInterestRate;

public BankAccount(){
m_iName="";
m_dBalance=0.0;
m_dInterestRate=0.0;
}

public BankAccount(String name, double balance, double interestRate) {
m_iName = name;
m_dBalance = balance;
m_dInterestRate = interestRate;
}

public String getM_iName() {
return m_iName;
}
public void setM_iName(String name) {
m_iName = name;
}
public double getBalance() {
return m_dBalance;
}
public void setM_dBalance(double balance) {
m_dBalance = balance;
}
public double getInterestRate() {
return m_dInterestRate;
}
public void setInterestRate(double interestRate) {
m_dInterestRate = interestRate;
}
public void printAccountMsg(){
System.out.println("帐户:&quo