Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Create an inheritance hierarchy that a bank might use to represent customer's bank accounts. All customers at this bank can deposit money into their accounts and withdraw money from their accounts. More specific types of accounts also exist. Saving accounts, for instance, earn interest on the money they hold. Checking accounts, on the other hand, charge a fee per transaction.
Create an inheritance hierarchy containing base class Account and derived classes SavingAccount and CheckingAccount that inherit from class Account. Base class Account should include one data member of type double to represent account balance. The class should include 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.0. if not, the balance should be set to 0.0 and the constructor should display error message, indicating that the initial balance is 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 getBalance should return the current balance.
Derived class SavingAccount should inherit the functionality of an Account, but also include a data member of type double indicating the interest rate assigned to the Account. SavingAccount's constructor should receive the initial balance, as well as an initial value for the SavingAccount's interest rate. SavingAccount should provide a public member function calculateInterest that returns a double indicating the amount of interest earned by an account. Member function calculateInterset should determine this amount by multiplying the interest rate by the account balance.
Derived class CheckingAccount should inherit from base class Account and include an additional data member of type double that represents the fee charged per transaction. CheckingAccount's constructor should receive the initial balance, as well as a parameter indicating a fee amount. Class CheckingAccount should redefine member functions credit and debit so that they subtract the fee from the account balance whenever either transaction is performed successfully. 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 withdraw. Then use the return value to determine whether a fee should be charged.]
After defining the classes in this hierarchy, write a program that creates objects of each class and tests their member functions. Add interest to SavingAccount object by first invoking its calculateInterest function, then passing the returned interest amount to the object's credit function.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M9642525

Have any Question?


Related Questions in Computer Engineering

Rock paper scissors please make sure it compiles and

Rock, Paper, Scissors (Please make sure it compiles and include output in answer.) You will implement a rock-paper-scissors game. The player enters 1 for Rock, 2 for Paper, or 3 for Scissors. The computer randomly select ...

You run a small pizza shop named pizza hat initially you

You run a small pizza shop named Pizza Hat. Initially you sold pizzas for $8 and every week you sold around 3000 pizzas. Each pizza costs you $3 to make. One day you decided to over discounts to customers to see if you c ...

Stepscreate a java project in eclipse called lab 2 next

Steps: Create a Java project in Eclipse, called Lab 2. Next create a java class called Dashboard. It should extend javafx.application.Application. This will be the main GUI for your lab, and it should use a VBox as the r ...

Question a as we have seen the internet layer of tcpip has

Question : (a) As we have seen, the Internet layer of TCP/IP has two protocols - IPv4 and IPv6. The transport layer provides two main protocols TCP and UDP (along with some special-purpose, minor protocols). But these ar ...

You have been recently promoted to it security manager your

You have been recently promoted to IT Security Manager. Your first job is to document the older hardware and software your company is currently using in the IT department. State the strengths and weaknesses with the curr ...

A bit-comparator is a combinational circuit with 2 inputs a

A Bit-Comparator is a combinational circuit with 2 inputs, A and B, and 3 outputs. L, E and G. Output L is 1 if A Output E is 1 if A = B, otherwise E is 0. Output G is 1 if A > B, otherwise G is 0. Show how the 2x4 decod ...

Red bull is the most popular energy drink in sales in the

Red Bull is the most popular energy drink in sales in the United States. Red Bull GmbH (the parent company) has observed that daily sales are normally distributed with an average of 6,329,903 drinks sold with a standard ...

Question consider a problem that you think can be addressed

Question: Consider a problem that you think can be addressed using AI/ML. Provide a detailed 1200-1500 words report that explains the problem and solution. And then explains the challenges associated with adoption of tha ...

In c languageread a double number as 2 digits after the

In C language: Read a double number as 2 digits after the decimal point. The number should have at least 6 digits BEFORE the decimal point. Extract all digits at even positions. Print them in reverse order. Extract all d ...

How to design a java program that reads a sentence say s

How to design a Java program that reads a sentence, say s, consisting of lower-case words with .nextLine() method, identifies the words using .indexOf() and .substring() methods and saves them in String variables. Then t ...

  • 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