Question: Write in C++ language Create an inheritance hierarchy containing base class Account and derived classes Savings Account and CheckingAccount that inherit from class Account. Data

 Write in C++ language Create an inheritance hierarchy containing base class

Write in C++ language Create an inheritance hierarchy containing base class Account and derived classes Savings Account and CheckingAccount that inherit from class Account. Data member Constructor Base class: Account Data member of type double to represent the account balance. 1pt Should receives an initial balance and uses it to initialize the data member. The 1pt constructor should validate the initial balance to ensure that it is greater than or equal to 0.0 (If not, the balance should be set to 0.0 and the constructor should display an error message, indicating that the initial balance was invalid) Member function credit should add an amount to the current balance 3pt . Member functions . Member function debit should withdraw money from the Account and ensure that the debit amount does not exceed the Account's balance. (If it does, the balance should be left unchanged and the function should print the message "Debit amount exceeded account balance"). Member function getBalance should return the current balance. Data member Constructor Member functions Derived class: SavingsAccount Data member of type double indicating the interest rate (percentage) assigned 1pt to the Account Should receive the initial balance, as well as an initial value for the 1pt Savings Account's interest rate Member function calculatelnterest that returns a double indicating the 2pt amount of interest earned by an account. Member function calculateInterest should determine this amount by multiplying the interest rate by the account balance. [Note: Savings Account should inherit member functions credit and debit as is without redefining them.] Data member Constructor 1pt 1pt Member functions 2pt Derived class: Checking Account Data member of type double that represents the fee charged per transaction. Should receive the initial balance, as well as a parameter indicating a fee amount Redefine member functions credit and debit as follows: CheckingAccount's versions of these functions should invoke the base-class Account version to perform the updates to an account balance. CheckingAccount's debit function should charge a fee only if money is actually withdrawn (ie, the debit amount does not exceed the account balance). [Hint: Define Account's debit function so that it returns a bool indicating whether money was withdrawn. Then use the return value to determine whether a fee should be charged.] 2pt Main function (to test classes ) Write a program that creates objects of each class and tests their member functions. Add interest to the SavingsAccount object by first invoking its calculatelnterest function, then passing the returned interest amount to the object's credit function

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!