Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Program: Create an inheritance hierarchy containing base class Account and derived classes SavingsAccount and CheckingAccount that inherit from class Account. Base class Account should include

Program: Create an inheritance hierarchy containing base class Account and derived classes SavingsAccount and CheckingAccount that inherit from class Account. Base class Account should include one data member of type double to represent the account balance.

Account Constructor o The class should provide a constructor that receives an initial balance, account number, and account owners name, and uses it to initialize the data member. The constructor should validate the initial balance to ensure that it's greater than or equal to 0.0.

o If not, the balance should be set to 0.0 and the constructor should display an error message, indicating that the initial balance is invalid.

Account member functions;

o Member function credit() should add an amount to the current balance.

o Member function debit() should withdraw money from the Account and ensure that the debit amount does not exceed the Account's balance.

0 If it does, the balance should be left unchanged and the function should print the message "Debit amount exceeded account balance."

o Member function getBalance() should return the current balance.

Derived class SavingsAccount should inherit the functionality of an Account, but also include a data member of type double indicating the interest rate(percentage) assigned to the Account.

o SavingsAccount's constructor should receive the initial balance, as well as an initial value for the SavingsAccount's interest rate.

o SavingsAccount should provide a public member function calculateInterest() that returns a double indicating the amount of interest earned by an account.

o Member function calculateInterest should determine this amount by multiplying the interest rate by the account balance.

o Note: SavingsAccount should inherit member functions credit and debit as is, without redefining them.

o CheckingAccount's debit() function should charge a fee only if money is actually withdrawn (i.e., the debit amount does not exceed the account balance).

o 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.

After defining the classes in this hierarchy, write a program that creates objects of each class and tests their member functions. Add interest to the SavingsAccount object by first invoking its calculateInterest() function, then passing the returned interest amount to the object's credit() function. Additionally, create a function to display all account information (account type checking or savings, account number, account owners name, and current balance).

Notes:

Please ensure to use single-line comments in your code wherever necessary to explain the functionality. marks will be deducted if the comments are not mentioned for each block of code logic

Submit seven files with naming conventions as follows:

o __main.cpp

o __Account.h

o __Account.cpp

o __SavingsAccount.h

o __SavingsAccount.cpp

o __CheckingAccount.h

o __CheckingAccount.cpp

DO NOT ZIP YOUR SUBMISSION

Use the same header filenames while declaring in the program for execution and as well as for submission. To elaborate, do NOT use differentheader file names for execution and change the file names to follow naming conventions for submission.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Marketing The New Profit Frontier

Authors: Ed Burnett

1st Edition

0964535629, 978-0964535626

More Books

Students also viewed these Databases questions