deposit()
and withdrawal()
need to return anything.deposit()
and withdrawal()
is to simply add the user input to the currentBalance
and save it in currentBalance
.println()
method and not updating the variable that is supposed to hold the balance. In fact, the first one should print false
(unless both deposit and oldBalance are zero). If you look at my code example, currentBalance += amount;
is shorthand for currentBalance = currentBalance + amount;
which means 'add this amount
to currentBalance
and store it in currentBalance
. Because I am reusing currentBalance, I eliminated the need for an oldBalance
variable.