Question: Assignment # 2 ( 1 0 points ) Create an inheritance hierarchy containing base class Account and derived class CheckingAccount that inherit from class Account.

Assignment # 2(10 points)
Create an inheritance hierarchy containing base class Account and derived class CheckingAccount that inherit from class Account.
\table[[Account class],[Data member,Data member of type double to represent the account balance.,1pt],[Constructor,\table[[Should receives an initial balance and uses it to initialize the data member. The],[constructor should validate the initial balance to ensure that it is greater than or],[equal to 0.0.],[(If not, the balance should be set to 0.0 and the constructor should display an],[error message, indicating that the initial balance was invalid).]],1pt],[\table[[Member],[functions]],\table[[- 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 Account's balance.],[(If it does, the balance should be left unchanged and the function should],[print the message "Debit amount exceeded account balance").]],2pt],[CheckingAccount class],[Data member,Data member of type double that represents the fee charged per transaction.,1pt],[Constructor,\table[[Should receive the initial balance, as well as a parameter indicating a fee],[amount]],1pt],[\table[[Member],[functions]],\table[[Redefine member functions credit and debit as follows:],[- 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 (i.e., 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 )],[\table[[- Write a pro],[class.]],\table[[gram that creates objects of each class and tests one member function for each]],1pt]]
 Assignment # 2(10 points) Create an inheritance hierarchy containing base class

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!