lundi 13 octobre 2014

Compile error when running simple program


Vote count:

0




I have a programming assignment where I am asked to write a class named Account with various methods etc. and a test program. I have completed it all but somethings wrong but I cannot figure what it is. Can annyone help me? The program won't compile.


import java.util.Date; public class Account {



private int id = 0;
private double balance = 0;
private double annualInterestRate = 0;
private static Date dateCreated = new Date();

Account(){
id = 0;
balance = 0;
annualInterestRate = 0;
dateCreated = new java.util.Date();
}
Account(int newId, double newBalance, double newAnnualInterestRate){
id = newId;
balance = newBalance;
annualInterestRate = newAnnualInterestRate;

}

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

public int setId(int newId){
return newId;

}

public double getBalance(double balance){
return balance;
}

public double setBalance(double newBalance){
return newBalance;

}

public double getAnnualInterestRate(double newAnnualInterestRate){
return newAnnualInterestRate;

}

public double setAnnualInterestRate(double newAnnualInterestRate){
return newAnnualInterestRate;

}

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

public double getMonthlyInterestRate(){
return balance * annualInterestRate / 12;
}

public double getMonthlyInterest(double getMonthlyInterestRate){
return balance * getMonthlyInterestRate;

}

public double withdraw(double amount){
return balance - (balance - amount);
}

public double deposit(double amount){
return (balance + amount) - balance;
}

}


public class testAccount {



public static void main(String[] args) {

Account account = new Account(1122, 20000, 4.5);
account.setId(1122);
account.setBalance(20000);
account.setAnnualInterestRate(4.5);
account.withdraw(2500);
account.deposit(3000);
account.dateCreated();

System.out.println("Balance is: " + account.balance);

}


}


asked 46 secs ago







Compile error when running simple program

Aucun commentaire:

Enregistrer un commentaire