posted 13 years ago
Kiaamaa,
I tried editing my code to look like yours but I got some serious errors when I ran the program. It compiled fine, but when I deposited $2000, it said my balance was $175. This is with a starting balance of $2175.
Also, the else statement does not execute when I enter zero or a negative number. I will post up what my AccountTest class looks like at the moment, as well as the Account class which defines the credit and debit methods.
Also, I should mention that nothing so far has done what I wanted it to do. I want to stop the next statement from printing after the user enters zero or a negative amount for debit, and then allow them to enter another number for debit. So basically, after they enter a negative number, the statement "Invalid amount. Try again." will appear and then the user can enter another number that does not execute the if clause.
So far, these suggestions have indeed made my program look more elegant, but the program still executes the next print line statement after a zero or negative number has been entered for the debit function.
EDIT:
Doh, sorry Kiaamaa. I got $175 for the withdrawal function. Got a little mixed up. Your code works just fine.
Account class:
AccountTest: