Question: In c++ create a Bank Account program: Create an inheritance hierarchy for banking accounts. Abstract base class Account has type double data members representing the

In c++ create a Bank Account program: Create an inheritance hierarchy for banking accounts. Abstract base class Account has type double data members representing the account balance, total credits, and total debits. The default ctor sets the account balance, total debits, and total credits to $0.00. Another ctor takes a double parameter to initialize the account balance also setting the account balance to $0.00 and issuing an error message if the value passed in was not positive number and setting total debits and total credits to $0.00. Member function credit() adds an amount to the current balance and total credits. Member function debit() withdraws money from the account, ensuring that the balance would not go negative prints an error message and leaves the balance unchanged if the debit amount exceeds the account balance; and if the withdrawal was successful, it adds to total debits. Member function getBalance() returns the account balance. Member function getCredits() returns the total credits. Member function getDebits() returns the total debits. Member functions credit() and debit() are virtual. Member function printAccnt() is pure virtual.

make the data members of Account protected.

Derived class Checking adds two data members of type double representing the fee charged for each transaction and the total transaction fees. Checkings ctor has parameters for the account balance and the transaction fee. Checking redefines debit() to subtract the fee from the account balance whenever a transaction is successfully performed Checkings debit() and credit() member functions also call assessFee(). Member function assessFee() subtracts the transaction fee from the balance, adds the fee to the total fees data member, and prints an error message if the account balance goes negative. Checkings printAccnt() reports the account balance, total credits, total debits, and total fee charges.

Derived class Savings adds a data member of type double representing the interest rate (percentage) assigned to the account. Savings ctor has parameters for the account balance and an initial value for the interest rate. Member function calculateInterest() reports the amount of interest earned by the account and adds the earnings to the account balance. Savings printAccnt() reports the total credits, total debits, and interest earned.

Derived class Senior inherits from Checking and adds a data member of type int representing the count of the debit() transactions. Seniors ctor has parameters for the account balance and the transaction fee and sets the debit count to zero. Senior redefines debit() to subtract the transaction fee from the account balance only whenever a debit() transaction is successfully performed AND when the debit count is four or fewer no charge for fifth and later debits. There is no fee for a deposit to a Senior account. Seniors printAccnt() reports the account balance, total credits, total debits, total fee charges, and the count of debits.

In your driver program create a vector of Account pointers to different Checking, Senior, and Savings account objects. After initializing the objects invoke the polymorphic printAccnt() on each of them, and after a series of polymorphic deposits and withdrawals for the various Account objects, again invoke the polymorphic printAccnt() on the accounts.

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!