Question: Problem Definition Create an inheritance hierarchy containing base class Account and derived class Savings-Account. Base class Account should include one data member of type double
Problem Definition
Create an inheritance hierarchy containing base class Account and derived class Savings-Account. Base class Account should include one data member of type double to represent the account balance. The class should provide a constructor that receives an initial balance and uses it to initialize the data member. The class should provide three member functions. Member function credit should add an amount to the current balance. Member function debit should withdraw money from the Account and ensure that the debit amount does not exceed the Accounts balance. 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. SavingsAccounts constructor should receive the initial balance, as well as an initial value for the SavingsAccounts interest rate. SavingsAccount should provide a public member function calculateInterest that returns a double indicating the amount of interest earned by an account. Member function calculateInterest should determine this amount by multiplying the interest rate by the account balance. [Note: SavingsAccount should inherit member functions credit and debit as is without redefining them.]
Part 1: Class Definition Implement the class definition for class Account and SavingsAccount in the files called Account.h and SavingsAccount.h. The class definition should contain only the prototypes of the member functions and double members. Part 2.1: Member-function definition Implement the member-function definition of classes in the files called Account.cpp and SavingsAccount.cpp. This .cpp file contains the actual implementation of the member functions of the two classes.
Part 2.1: Member-function definition Implement the member-function definition of classes in the files called Account.cpp and SavingsAccount.cpp. This .cpp file contains the actual implementation of the member functions of the two classes.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
