求java大神帮忙编个程序

2025-03-27 11:53:26
推荐回答(1个)
回答1:

Class Account{
private int id;
private double balance;
private double annuallnterestRate;
private Date dateCreated;

public Account(){
this.id = 0;
this.balance = 0;
this.annuallnterestRate = 0;
this.dateCreated = new Date();
}

public Account(int id, double balance){
this.id = id;
this.balance = balance;
this.dateCreated = new Date();
}

public int getId(){
return this.id;
}

public void setId(int id){
this.id = id;
}

public double getBalance(){
return this.balance
}

public void setBalance(double balance){
this.balance = balance;
}

public double getAnnuallnterestRate(){
return this.annuallnterestRate
}

public void setAnnuallnterestRate(double annuallnterestRate){
this.annuallnterestRate = annuallnterestRate
}

public Date getDateCreated(){
return this.dateCreated;
}

public double getMonthlyInterestRate(){
double monthlyInterest = java.lang.StrictMath.pow(this.annuallnterestRate,1.0/12)-1;
return monthlyInterest;
}

public String withdraw(double amount){
this.balance = this.balance-amount;
return "withdraw success";
}

public String deposit(double amount){
this.balance = this.balance+amount;
return "deposit success";
}

public static void main(String[] args){
Account account = new Account(1122,20000.00);
account.setAnnuallnterestRate(0.045);
account.withdraw(2500.00);
account.deposit(3000.00);
System.out.println(account.getBalance());
System.out.println(account.getMonthlyInterestRate());
System.out.println(account.getDateCreated());
}

}
不谢!分数拿来~
请采纳。