Create an inheritance hierarchy that a bank might use

Assignment Help C/C++ Programming
Reference no: EM132183882

Question: C++ Programming.

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).

1. Create a base class Account. Base class Account should include

• One data member of type double to represent the account balance.

• 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 an error message, indicating that the initial balance was invalid.

• 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.

2. Derived class SavingsAccount should inherit the functionality of an Account, but also include

• One data member of type double indicating the interest rate (percentage) assigned to the Account.

• A constructor that receives the initial balance, as well as an initial value for the interest rate.

• Member function calculateInterest that returns a double indicating the amount of interest earned by an account. Member function calculateInterest should determine this amount by multiplying the interest rate by the account balance.

3. Derived class CheckingAccount should inherit from base class Account and also include

• One data member of type double that represents the fee charged per transaction.

• A constructor that receives 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 withdrawn. 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 the SavingsAccount object by first invoking its calculateInterest function, then passing the returned interest amount to the object's credit function.

Reference no: EM132183882

Questions Cloud

Develop a product service idea : Develop a product service idea. Describe the product/service including the benefits of using the product/service.
Monthly average for the year : Once all 12 months data is entered then loop through the array and calculated the total sales for the year and the monthly average for the year.
Research the affects cannabis has on pain : My idea for the assignment is a storefront or online business for people who suffer from pain and who have anxiety/ depression and want to treat it.
Prepare a marginal cost of capital schedule : Prepare a marginal cost of capital schedule for the company and use a graph to illustrate it. (You need to determine, the cost of debt (YTM)
Create an inheritance hierarchy that a bank might use : Create an inheritance hierarchy that a bank might use to represent customers' bank accounts. All customers at this bank can deposit (i.e., credit).
What is the NPV of this project : The effective tax rate is 40 percent and the required rate of return is 22 percent. What is the NPV of this project
How have other people in the past tried to solve-answer it : Why is this problem/question worth solving/asking? Who would care? How have other people in the past tried to solve/answer it?
Presentation-the content or the design : 1. Which is more important about a presentation-the content or the design? Why?
How does this impact the npv and roi and the roi : The school can either encourage graduates to give more. How does this impact the NPV and ROI and the ROI? Is this a good plan

Reviews

Write a Review

 

C/C++ Programming Questions & Answers

  Determining the second derivative of the distance function

Write a program that approximates the force that a race car's brakes are exerting during a high-speed stop, given a table of the distances that the car.

  Accomplish the preceding task

However, the customer details maintenance application crashed as Dwayne mistakenly entered the wrong file path. Therefore, he asks Elina to modify the application so that it does not crash due to similar errors. Modify the code that Elina needs to ..

  Flipflapsthe project is to design and write a c 11fltk game

flipflapsthe project is to design and write a c 11fltk game program with a graphical user interface.the game is based

  Create your own function

Create your own function in C that accepts one input parameter and returns a float number. You decide the theme. You should C code and an example call. Be sure to provide an overview of what your function is doing

  Write a program that uses the class salariedemployee

Write a program that uses the class SalariedEmployee shown below. Your program is to define a class called Administrator, which is to be derived from the class SalariedEmployee. You are allowed to change private in the base class to protected. You..

  Function definitions of the pixel class constructor

Write client code to print out the current X and coordiantes and the status of the first pixel

  Main program should instantiate an instance

The main program should instantiate an instance of the class Rectangle and then make calls to the member functions to input the data and output the results

  Write a c program that creates a union named users

Write a C program that creates a union named "users" with two members (last name and email).

  Define the cheetah constructor to accept and initialize

Design and implement a class called Cheetah that contains instance data that represents the cheetah's name, age, weight, length and gender.

  What are a class and a structure?

What are a class and a structure?

  Prepare a program to palindrome function.

A palindrome is a string whose reversal is identical to the original string.  How many strings using decimal digits (0,1,2,.....,9) of length n are palindromes?

  Dynamicword that holds a pointer

Consider the following main function.  Assume that DynamicWord.h contains a class definition for a class called DynamicWord that holds a pointer to a dynamic array as a private data member, but the assignment operator (=) has not been overloaded for ..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd