Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C++ Description Create an inheritance hierarchy that a bank might use to represent customers' bank accounts. All customers at this bank can deposit (i.e.,

In C++

image text in transcribedimage text in transcribed

Description Create an inheritance hierarchy that a bank might use to represent customers' bank accounts. All customers at this bank can deposit (i.e., credit) money into their accounts and withdraw it (i.e. debit) money from their accounts. More specific types of accounts also exist. Savings accounts, for instance, can earn interest on the money they hold. Checking accounts, on the other hand, charge a fee per transaction (i.e, credit or debit) Create an inheritance hierarchy containing base class Account and derived classes Savings account and Checking_account that inherit from base class 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 constructor should validate the initial balance to ensure that it is greater than or equal to 0. If not, the balance should be set to 0 and the constructor should display an error message, indicating that the initial balance was invalid. 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 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 get balance should return the current balance Derived class Savings_account should inherit the functionality of an Account, but also include a data member of type double indicating the interest (percentage) assigned to the Account. Savings_ account's constructor should receive the initial balance, as well as an initial value for the Savings account's interest rate. Savings account should provide a public member function calculate interest that returns a double indicating the amount of interest earned by an account. Member function calculate_interest 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 should inherit from base class Account and include an additional data member of type double that represents the fee charged per transaction. Checking account's constructor should receive the initial balance, as well as a parameter indicating a fee amount. Class Check account should redefine member functions credit and debit so that they subtract the fee from the account balance whenever either transaction is performed successfully. Checking_account's versions of these functions should invoke the base-class Account version to perform the updates to an account balance. Checking_account's debit function should charge a fee only if money is actually

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

Databases Illuminated

Authors: Catherine M. Ricardo

1st Edition

0763733148, 978-0763733148

More Books

Students also viewed these Databases questions

Question

Find y'. y= |x + X (x) (x) X 1 02x+ 2x 1 O 2x + 1/3 Ex 2x +

Answered: 1 week ago

Question

What is the basis for Security Concerns in Cloud Computing?

Answered: 1 week ago

Question

Describe the three main Cloud Computing Environments.

Answered: 1 week ago