Question: Complete the code in C++ Introduction Create an inheritance hierarchy that a bank might use to represent customers bank accounts. All customers can deposit (credit)

Complete the code in C++

Introduction

Create an inheritance hierarchy that a bank might use to represent customers bank accounts. All customers can deposit (credit) into their accounts and withdraw (debit) from their accounts. More specific types of accounts also exist. Savings accounts, for instance, earn interest on the money they hold. Checking accounts, on the other hand, can charge a fee per transaction. Create an inheritance hierarchy containing base class Account and derived classes SavingsAccount and CheckingAccount that inherit from Account.

Deliverables

A driver program (driver.cpp)

An implementation of Account class (account.h, account.cpp)

An implementation of SavingsAccount (savingsaccount.h, savingsaccount.cpp)

An implementation of CheckingAccount (checkingaccount.h, checkingaccount.cpp)

1 Account class

Implement the base class.

1.1 Data Members

balance (double)

1.2 Member Functions

Constructors

Defines default and paramaterized constructors. Confirm balance not below zero. If so, set to zero and output an error message.

Destructor

Defines destructor. Clean up any allocated memory.

Accessors

double getBalance()

Mutators

void debit(amount) Withdraws from the account if the amount does not exceed the balance. If so, nothing is debited and an error message is printed. This method may change when you implement the derived class.

void credit(amount)

Deposits into the account.

2 SavingsAccount class

Implement the derived class.

2.1 Data Members

interestRate (double). This value should be [0, 1.0]

2.2 Member Functions

Constructors

Defines default and parameterized constructor. Confirm interestRate not below zero. If so, set to zero and output an error message.

Destructor

Defines destructor. Clean up any allocated memory.

Accessors

double calcInterest() Returns the current interest of the account (balance multiplied by interest rate).

3 CheckingAccount class

Implement the derived class.

3.1 Data Members

feeForTransaction (double)

3.2 Member Functions

Constructors

Defines default and parameterized constructor. Confirm feeForTransaction not below zero. If so, set to zero and output an error message.

Destructor

Defines destructor. Clean up any allocated memory.

Mutators

void debit(amount) Invokes the base class debit member function and subtracts the fee if successful debit (Hint: redefine parent method to return a value you can check).

void credit(amount) Invokes the base class credit member function and subtracts the fee. (Yes, it is terrible for this bank to charge you to deposit money which they are profiting from investing, but thats just the way life goes sometimes.)

4 The Driver Program

In your driver, prompt the user for input as shown below. Create a vector of six Account pointers (alternating Checking then Saving) and point them to objects you initialize with the users input. Then, create a loop that, for each account, allows the user to deposit and withdraw from the account using the appropriate member functions. As you process each account, determine its type. If it is a SavingsAccount, calculate and add interest after the deposit. After processing each account, print the updated balance by invoking the base-class member function getBalance().

4.1 Example output:

Checking Account 0

Please enter the balance:

Please enter the fee:

Savings Account 1

Please enter the balance:

Please enter the interest rate:

(repeat for Accounts 3 through 6)

Account 1 balance: $70.00

Enter an amount to withdraw from Account 1: 80.00

Debit amount exceeded account balance.

Enter an amount to deposit into Account 1: 35.00

$1.00 transaction fee charged.

Updated Account 1 balance: $104.00

Account 2 balance: $80.00

Enter an amount to withdraw from Account 2: 10.00

Enter an amount to deposit into Account 2: 35.00

Adding $5.00 interest to Account 2 (a SavingsAccount)

Updated Account 2 balance: $110.00

(repeat for Accounts 3 through 6)

Submit the following files to Canvas (named EXACTLY as shown below)

1. driver.cpp

2. account.h

3. account.cpp

4. savingsaccount.h

5. savingsaccount.cpp

6. checkingaccount.h

7. checkingaccount.cpp

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!