Remove the =0.03 from the declaration (line 11).
balance is a parameter of enterAccountData(), so it goes out of scope once that method ends. Use accountBal in computeInterest() instead.
jonsca
Quantitative Phrenologist
5,621 posts since Sep 2009
Reputation Points: 1,165
Solved Threads: 581
In the first place, you cannot assign a const value in the class header. Second, you didn't declare the variable balance in the void computeInterest() function
Nichito
Posting Virtuoso
1,602 posts since Mar 2007
Reputation Points: 424
Solved Threads: 57
Actually, you don't use the balance you are passing in anyway. Remove that parameter. Assign it to accountBal *after* the user enters it in. Now the object will carry the accountBal around (and you can access it from all of the other methods).
jonsca
Quantitative Phrenologist
5,621 posts since Sep 2009
Reputation Points: 1,165
Solved Threads: 581
Yes, that's exactly it. The order in which you were doing it before was writing 0 to the variable (that you had passed in), taking input to write over the variable you had passed in. accountBal wasn't getting anything but the 0.
jonsca
Quantitative Phrenologist
5,621 posts since Sep 2009
Reputation Points: 1,165
Solved Threads: 581
You've got months and counter flipped around. Count up until you reach months, not the other way around.
jonsca
Quantitative Phrenologist
5,621 posts since Sep 2009
Reputation Points: 1,165
Solved Threads: 581
while(counter < months) I meant, sorry.
counter = 0, counter < months = true, loop continues
counter = 1, counter < months = true, loop continues
...
counter = months, counter < months = false, loop stops.
jonsca
Quantitative Phrenologist
5,621 posts since Sep 2009
Reputation Points: 1,165
Solved Threads: 581