Bring together classes, inheritance, and exception handling to model a simple bank. You'll have a base Account class and a SavingsAccount that extends it.
YOUR TASK
Create a program that:
Defines a BankAccount class with Owner and Balance
Has Deposit(double amount) and Withdraw(double amount) methods
Throws an exception if withdrawal exceeds balance
Defines a SavingsAccount that inherits BankAccount and adds InterestRate
Has an ApplyInterest() method that increases balance by the rate
Demonstrates: deposit, withdraw, interest, and a failed overdraft
Need a hint?
Structure:
1. class BankAccount { public string Owner; public double Balance; }
2. In Withdraw: if (amount > Balance) throw new Exception("Insufficient funds");
3. class SavingsAccount : BankAccount { public double InterestRate; }
4. ApplyInterest: Balance += Balance * InterestRate;
5. Use try/catch around the overdraft attempt
Console initialized...
Ready for Project 4: Banking System
> Test your code with the "Check My Code" button
> When it passes, the Complete button will activate!