CJCoding With Joseph
15free / daySign inCreate account

Bank Account Deposit and Withdraw Class

Create a class named BankAccount that stores a balance in an integer field. Give it a constructor that takes a starting balance and saves it. Add a method Deposit(int amount) that adds the amount to the balance, a method Withdraw(int amount) that subtracts the amount from the balance, and a method GetBalance() that returns the current balance. The runner code will create an account, call Deposit and Withdraw, then print GetBalance() — so your methods must actually change the stored field.

Expected Output:

120

= newline. The output ends with a newline — print one after the last line.

Hints4 available
Topics:
Classes
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cw, cr, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.