Savings account balance comparison code.
I have a savings account assignment which includes the following step:
a public method of the appropriate type called equals, as per Java requirements, it will compare two accounts and return true if both
savingsBalance values are the same - accurate to 4 digits after the decimal point (HINT: use strings).
I've used the following code to convert the savings balance to a string:
public String currentBalance()
String currentBalance = "" + four.format(savingsBalance);
This is called from the main program by:
String acctOne = acct1.currentBalance();
String acctTwo = acct2.currentBalance()
If I put this code:
public boolean equals() //this is line 40
System.out.println("The account balances are equal.");
System.out.println("The account balances are not equal.");
in my main file then I get the following error messages on line 40:
illegal start of expression
If I remove the word public then I don't get the illegal start message but I still get the ; expected one.
If I put the boolean method into my program file (which is where I suspect it should be) then it can't find the values because they are calling objects in the main file.
Can anyone tell me what I'm doing wrong please?