Question: The base class Account : The class contains following private data members: accountNumber (integer from 1000 to 4999), accountOwner (name as a string), accountBalance (type

The base class Account:

The class contains following private data members: accountNumber (integer from 1000 to 4999), accountOwner (name as a string), accountBalance (type double).

The constructor receives account number, account owners name, and an initial balance as parameters. If the initial balance is less than 0.0 the constructor should set the account balance to 0.0 and also issue an error message such as Initial balance was invalid.

The class provides three member functions:

credit: adds an amount to the current balance.

debit: withdraw money from the account and ensure that the debit amount does not exceed the current balance. if it does, the balance should be left unchanged, and the function should print the message likes Debit amount exceeded account balance.

getBalance: returns and print out the current balance. This is a const function.

Derived class: SavingsAccount

The SavingsAccount should inherit the functionality of an Account, but also include a private data member interestRate (type double value such as 0.03).

The constructor receives an account number, account owners name, an initial balance, as well as initial value of interest rate.

This class should provide a public member function calculateInterest which returns the amount of interest that is calculated by multiplying the interest rate with the account balance. Dont add the interest to account balance using this function,

The class should inherit credit and debit without redefining them.

Derived class: CheckingAccount

The CheckingAccount includes a new data member fee (type double) that represent the fee charged per transaction.

The constructor should receive the account number, account owner, initial balance and a parameter indicating a fee amount.

It should redefine the credit and debit function so that they subtract the fee from account balance whenever each transaction is performed successfully. The debit function should charge the fee only if money is actually withdrawn.

Write a test driver program that creates objects of all three classes (Account, SavingsAccount, and Checking Account) and tests their member functions. In testing the SavingAccount, add interest to the SavingsAccout object by first invoking its calculateInterst function, then passing the returned interest amount to the objects 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!