← Back to Classes
Question 513
Account That Refuses Overdrafts
Account That Refuses Overdrafts
Write the whole BankAccount class. The constructor stores owner and a float balance; deposit(amount) adds to the balance; withdraw(amount) subtracts from it, unless amount is more than the balance, in which case it prints exactly Insufficient funds and changes nothing. Do NOT write a main block or any top-level test code; the tests construct the class. Input: two lines, a deposit amount and then a withdrawal amount, which the tests read as floats and apply in that order to an account opened with 100.0 before printing the final balance.
Expected Output:
30.0= newline. The output ends with a newline — print one after the last line.
Hints3 available
Sign in to use hintsTopics:
Classes
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (pr, inp, def)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.