I am new to java and I am still trying to learn the basics, I'm guessing I've probably made a very simple error. I am trying to create a code where two objects of the class savingsAccount are incremented by a monthly interest. Here is the code that I wrote:
class SavingsAccount {
//main
public static void main(String args[]){
savingsAccount saver1 = new savingsAccount(2000.0);
savingsAccount saver2 = new savingsAccount(3000.0);
savingsAccount.modifyAnnualInterestRate(0.04f);
System.out.println("S1: " + saver1);
System.out.println("S2: " + saver2);
savingsAccount.modifyAnnualInterestRate(0.05f);
System.out.println("S1: " + saver1);
System.out.println("S2: " + saver2);
}
//end main
static double annualInterestRate;
private double savingsBalance;
public void savingsAccount(double balance){
savingsBalance = balance;
}
public double calculateMonthlyInterest(){
return (savingsBalance * annualInterestRate)/12;
}
public static void modifyInterestRate(double rate){
annualInterestRate = rate;
}
public double getAnnualInterestRate(){
return annualInterestRate;
}
public double getSavingsBalance(){
return savingsBalance;
}
}
When I attempt to run the code, these errors are returned:
SavingsAccount.java:29: error: cannot find symbol
savingsAccount saver1 = new savingsAccount(2000.0);
^
symbol: class savingsAccount
location: class SavingsAccount
SavingsAccount.java:29: error: cannot find symbol
savingsAccount saver1 = new savingsAccount(2000.0);
^
symbol: class savingsAccount
location: class SavingsAccount
SavingsAccount.java:30: error: cannot find symbol
savingsAccount saver2 = new savingsAccount(3000.0);
^
symbol: class savingsAccount
location: class SavingsAccount
SavingsAccount.java:30: error: cannot find symbol
savingsAccount saver2 = new savingsAccount(3000.0);
^
symbol: class savingsAccount
location: class SavingsAccount
SavingsAccount.java:31: error: cannot find symbol
savingsAccount.modifyAnnualInterestRate(0.04f);
^
symbol: variable savingsAccount
location: class SavingsAccount
SavingsAccount.java:36: error: cannot find symbol
savingsAccount.modifyAnnualInterestRate(0.05f);
^
symbol: variable savingsAccount
location: class SavingsAccount
6 errors
If anyone could help me with this, I would be very grateful. Thank you!