Ledis15
2012-04-04 18:40:42 UTC
Exercise08_07.java:33: error: invalid method declaration; return type required
public account() {
^
1 error
public class Exercise08_07 {
public static void main (String[] args) {
account myAccount = new account();
myAccount.setId(1122);
myAccount.setBalance(20000, 2500, 3000);
myAccount.setAnnualInterestRate(.045);
System.out.println(myAccount.toString());
}
}
class Account {
// Implement it
private int id;
private double balance;
private double annualInterestRate;
private double withdraw;
private double deposit;
private double monthlyInterestRate;
public account() {
id = 0;
balance = 0;
annualInterestRate = 0;
}
public void setId(int i) {
id = i;
}
public int getId() {
return id;
}
public void setBalance(double bal, double wd, double dep) {
balance = bal;
withdraw = wd;
deposit = dep;
}
public double getBalance() {
return balance - withdraw + deposit;
}
public void setAnnualInterestRate(double air) {
annualInterestRate = air;
}
public double getAnnualInterestRate() {
return annualInterestRate;
}
public String toString() {
String printAccount = "";
printAccount += "For account: " + id + "\nBalance: " +
balance + "\nMonthly Interest Rate: " +
monthlyInterestRate;
return printAccount;
}
}