Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Question: (Account Inheritance Hierarchy) 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 (i.e., debit) money from their accounts. More specific types of accounts also exist. Savings accounts, for instance, 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 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's 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.

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 rate (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 Checking 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 withdrawn (i.e., the debit amount does not exceed the account balance). After defining the classes in this hierarchy, 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 calculate Interest function, then passing the returned interest amount to the object's credit function.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M92418966
  • Price:- $10

Priced at Now at $10, Verified Solution

Have any Question?


Related Questions in Computer Engineering

In unix programming ordinarily the exec system call follows

In UNIX programming, ordinarily the exec() system call follows the fork() call. Explain what would happen if a programmer were to inadvertently place the call to exec() before the call to fork().

What are some examples of marketing activities that are

What are some examples of "marketing" activities that are associated with the Summer Olympics? How does global marketing and the use of new digital marketing techniques facilitate marketing activities at the Olympics in ...

Question 1 why is it critical for an organization to have a

Question: 1. Why is it critical for an organization to have a DoS attack response plan well before it happens? 2. Please discuss the techniques used by malware developers to disguise their code and prevent it from being ...

Research the history of specification languages and write a

Research the history of specification languages, and write a report on the successes or failures of some of these languages. Include 5 languages which are successful and 5 which have failed. All work should be typed writ ...

Can someone help me with this question you need step by

Can someone help me with this question? You need step by step and You need names of any theorms or formulas you are using please. The Codechef Programming Society has 198 membership-paying mem- bers, 97 females and 101 m ...

Problemtelephone calls arrive at the rate of 12 per hour at

Problem Telephone calls arrive at the rate of 12 per hour at the reservation desk for Regional Airways. a. Find the probability of receiving 3 calls in a 4-minute interval. If required, round your answer to four decimal ...

Answer the following question a suppose alice shares a

Answer the following Question : a. Suppose Alice shares a secret block cipher key, K_AB with Bob, and a different secret block cipher key, K_AC with Charlie. Describe a method for Alice to encrypt an m-block message such ...

Question when we studied clusters we discovered that

Question : When we studied clusters we discovered that semaphores, the mechanism we rely on for mutual exclusion, don't work, and so we studied message-passing as an alternative that does work on clusters. Why do semapho ...

One of the basic motivations behind the minimum spanning

One of the basic motivations behind the Minimum Spanning Tree Problem is the goal of designing a spanning network for a set of nodes with minimum total cost. Here we explore another type of objective: designing a spannin ...

Structured programming is a subset of procedural

Structured programming is a subset of procedural programming. If structured programming promotes the creation of good code and procedural programs are easier to maintain, why do you need to shift to OOP? What are the pro ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As