Author | Message |
---|---|
disrael
Posts: 44
|
Posted 12:51 Oct 11, 2013 |
I'm just a little confused on what I'm doing wrong or what I'm missing from my code. This is my code and I can't seem to get the balance to print right. If anyone has any suggestions it would be very welcomed. Balance keeps coming up as 0.0.
Last edited by disrael at
15:47 Oct 11, 2013.
|
Eric Liao
Posts: 158
|
Posted 09:29 Oct 12, 2013 |
The balance is 0.0 is because that by default java will initialize double to be 0. Which at your case, the bankAcc variable is never modified. The reason the bankAcc is never modified is that you haven't called the method addDeposit(double deposit). A simple way to fix: call addDeposit(100) in the main method and see what happen! (hint: you probably need to add static to the method) --- A minor note: I would recommend to construct a BankAccount class that is separated from BankAccountTester, and in BankAccountTester, you just need to construct a BankAccount and call addDeposit() method test. |