Home /
Expert Answers /
Computer Science /
1-derived-classes-of-account-in-week-9-lab-exercise-1-we-created-the-account-class-to-model-a-b-pa433
(Solved): 1. (Derived classes of Account) In Week 9 Lab Exercise 1, we created the Account class to model a b ...
1. (Derived classes of Account) In Week 9 Lab Exercise 1, we created the Account class to model a bank account. An account has the properties account number, balance, and annual interest rate, and functions to deposit and withdraw. Create two derived classes for checking and savings accounts. A checking account has an overdraft limit, but a savings account cannot be overdrawn. Also, a savings account has a maximum deposit limit. Define a constant virtual tostring () function in the Account class and override it in the derived classes to return the account number and balance as a string. - Draw the UML diagram for the classes - Implement the classes - Write a test program that creates objects of Account, SavingsAccount, and CheckingAccount with initial balances of £20,000 each and annual interest rates of 2% for the Account and CheckingAccount objects, and 5% for the SavingsAccount object - Invoke their toString () functions at each withdrawal or deposit. Attempt to overdraw the checking account (give it an overdraft limit of f2000) and deposit above the limit for the savings account (give it a deposit limit of f1000) A sample run is shown here: Account 1432 has a balance of £20000.00 Checking account 1433 has a balance of £20000.00 Savings account 1434 has a balance of £20000.00 Withdrawing £2000.00 from account 1432 Account 1432 has a balance of £18000.00 Attempting to withdraw £5000.00 from checking account 1433 Checking account 1433 has a balance of £15000.00 Attempting to withdraw £20000.00 from checking account 1433 Failed: withdrawal will exceed overdraft limit of £2000.00 for this checking account Checking account 1433 has a balance of £15000.00 Depositing £1000.00 to account 1432 Account 1432 has a balance of £19000.00 Attempting to deposit £500.00 to savings account 1434 Savings account 1434 has a balance of £20500.00 Attempting to deposit £10000.00 to savings account 1434 Failed: deposit will exceed limit of £1000.00 for this savings account Savings account 1434 has a balance of £20500.00