CJCoding With Joseph
15free / daySign inCreate account

Encapsulated Bank Account

Build a class BankAccount from scratch. Requirements:
- a private double balance set by the constructor from a starting amount
- Deposit(double amount) adds to the balance, but ignores a negative amount
- Withdraw(double amount) subtracts from the balance, but ignores a negative amount and ignores any withdrawal larger than the current balance
- a read-only Balance property returns the balance

Do not write a Main method.

Starting at 100, after Deposit(50) then Withdraw(30) the program prints the output shown in Expected Output.

Expected Output:

120

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

Hints4 available
Topics:
Encapsulation
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.