Your current issue is that you didn’t use camelCasedNames when you defined the annualInterestRate
field, so it doesn’t exist! It’s currently named annualinterestrate
instead (note there are no caps!). You ought to rename it to match what you’re using elsewhere.
Also, that field in particular has another problem, which is that you’ve declared it final
. That means you can’t modify it after the object is created, so your setAnnualInterestRate
method is doomed to fail anyway unless you remove the final
modifier. So that field declaration should look like this:
private double annualInterestRate = 0.12;
Your naming conventions in general are obviously giving you some serious grief. You indicated in the comments that you don’t want to use the this
keyword since your instructor hasn’t introduced it yet, and that’s fine, but you should at least name your variables in some way that it’s obvious from looking at it what’s going on and whether it will work. Prefixing variable names with a lowercase "a"
is not the answer. Instead, consider a meaningful prefix or suffix if you need to avoid naming conflicts. For example:
public void setBalance (double newBalance)
{
balance = newBalance;
}
You’ve got other spelling errors elsewhere, including in your AccountTester
class. You need to go through your code carefully and make sure the names match up exactly. Working with an IDE like Eclipse or NetBeans with live compilation warnings and auto-completion will likely save you a lot of trouble.
4
solved Object and Classes: Finding balance ,annual interest rate, monthly interest rate, withdrawing, depositing [closed]