Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1pt Create an inheritance hierarchy containing base_class Account and derived classes Savings Account and Checking Account that inherit from class Account Base class Account Data
1pt Create an inheritance hierarchy containing base_class Account and derived classes Savings Account and Checking Account that inherit from class Account Base class Account Data member Data member of type double to represent the account balance Constructor Should receives an initial balance and uses it to initialize the data member. The ipt constructor should validate the initial balance to ensure that it is greater than or equal to 0.0 Kif not the balance should be set to 0.0 and the constructor should display an error message, indicating that the initial balance was invalid), Member function Setcredit should add an amount to the current balance. 3pt functions Member Member function Setdebit should withdraw money from the Account and ensure that the debitamount does not exceed the Account's balance kif it does the balance should be left unchanged and the function should print the message "Debit amount exceeded account bafance") Member function getBal should return the current balance Type here to search 5 Desktop AENG 11:16 AM 2/7/2021 Derived class Checking Account Data member Data member of type double that represents the fee charged per transaction 1 Constructor Should receive the initial balance, as well as a parameter indicating a tee 1Rt amount Member functions Redefine member functions Set credit and Set debit as follows 2pt CheckingAccount's versions of these functions should invoke the base-class Account version to perform the updates to an account balance CheckingAccount's debit function should charge a fee only if money is actually withdrawn (ie, the debit amount does not exceed the account balance), 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 2pt Main function (to test classes) Write a program that creates objects of each class and tests their member functions Adid interest to the SavingsAccount object by first invoking its calculatelnterest function, then passing the returned interest amount to the object's credit function. 5 Type here to search LI Desktop ENG 11:18 AM 2/7/2021 Derived class: Savings Account Data member Data member of type Float indicating the interest rate (percentage) assigned ipt to the Account Constructor Member functions Should receive the initial balance as well as an initial value for the 1 pt Savings Account's interest rate Member function calculateInterest that returns a double Indicating the amount 2pt 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 inhent member functions credit and debit as is without redefining them! Derived class Checking Account Data member Data member of type double that represents the fee charged per transaction. 1pt Constructor Should receive the initial balance, as well as a parameter indicating a fee ipt amount 2pt Member Redefine member functions Setcredit and Set debit as follows. functions CheckingAccount's versions of these functions should invoke the base-class Account version to perform the updates to ana count balance Type here to search HI > 1 Desktop ENG 11:18 AM 2/1/2021
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started