Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

by using C++ language Assignment #3 (15 points) Create an inheritance hierarchy containing base class Account and derived classes Savings Account and CheckingAccount that inherit

by using C++ language

image text in transcribed

Assignment #3 (15 points) Create an inheritance hierarchy containing base class Account and derived classes Savings Account and CheckingAccount that inherit from class Account Base class: Account Data member Data member of type double to represent the account balance. 1pt Constructor Should receives an initial balance and use it to initialize the data member. The 1pt 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). Member Member function credit should add an amount to the current balance. 3pt functions 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"). Member function getBalance should return the current balance. Derived class: Savings Account Data member Data member of type double indicating the interest rate (percentage) assigned ipt to the Account Constructor Should receive the initial balance, as well as an initial value for the 1pt Savings Account's interest rate. Member Member function calculateInterest that returns a double indicating the 2pt functions amount of interest eamed by an account Member function calculateInterest should determine this amount by multiplying the interest rate by the account balance. (Note: Savings Account should inherit 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 1pt amount Member Redefine member functions credit and debit as follows: 2pt functions CheckingAccount's versions of these functions should invoke the base-dass 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 Write a program that creates objects of each class and tests their member functions. Add interest to the Savings Account object by first invoking its calculateinterest function, then passing the returned interest amount to the object's credit function. Assignment #3 (15 points) Create an inheritance hierarchy containing base class Account and derived classes Savings Account and CheckingAccount that inherit from class Account Base class: Account Data member Data member of type double to represent the account balance. 1pt Constructor Should receives an initial balance and use it to initialize the data member. The 1pt 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). Member Member function credit should add an amount to the current balance. 3pt functions 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"). Member function getBalance should return the current balance. Derived class: Savings Account Data member Data member of type double indicating the interest rate (percentage) assigned ipt to the Account Constructor Should receive the initial balance, as well as an initial value for the 1pt Savings Account's interest rate. Member Member function calculateInterest that returns a double indicating the 2pt functions amount of interest eamed by an account Member function calculateInterest should determine this amount by multiplying the interest rate by the account balance. (Note: Savings Account should inherit 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 1pt amount Member Redefine member functions credit and debit as follows: 2pt functions CheckingAccount's versions of these functions should invoke the base-dass 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 Write a program that creates objects of each class and tests their member functions. Add interest to the Savings Account object by first invoking its calculateinterest function, then passing the returned interest amount to the object's credit function

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

How To Build A Million Dollar Database

Authors: Michelle Bergquist

1st Edition

0615246842, 978-0615246840

More Books

Students also viewed these Databases questions