Develop polymorphic banking program using account hierarchy

Assignment Help Basic Computer Science
Reference no: EM131610305

Question: (Polymorphic Banking Program Using Account Hierarchy) Develop a polymorphic banking program using the Account hierarchy created in Exercise. Create a vector of Account pointers to Savings Account and Checking Account objects. For each Account in the vector, allow the user to specify an amount of money to withdraw from the Account using member function debit and an amount of money to deposit into the Account using member function credit. As you process each Account, determine its type. If an Account is a Savings Account, calculate the amount of interest owed to the Account using member function calculate Interest, then add the interest to the account balance using member function credit. After processing an Account, print the updated account balance obtained by invoking base-class member function get Balance.

Exercise: (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. 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.

Reference no: EM131610305

Questions Cloud

Define the field of criminal justice : Why is it important to conduct research in the field of criminal justice. Can research benefit the criminal justice field as a whole. If so, how
Create a program that displays the address information : (Package Inheritance Hierarchy) Use the Package inheritance hierarchy created in Exercise to create a program that displays the address information.
Can be terminated at any time by either party : It is a common-law rule between the employer and the employee that the employment contract can be terminated at any time by either party.
Define what is their core philosophy : What is their core philosophy. What are the pros and cons of this philosophy. Elaborate
Develop polymorphic banking program using account hierarchy : (Polymorphic Banking Program Using Account Hierarchy) Develop a polymorphic banking program using the Account hierarchy created in Exercise.
Explain description of the crime that took place : Outline the level of court that was assigned to the case local/state, municipal, or federal and the reason why that level was appropriate
Which employers are subject to affirmative action laws : Which employers are subject to Affirmative Action laws? What potential impact does Affirmative Action have on employees and the workplace?
Discuss an abstract class carbon footprint : (Carbon Footprint Abstract Class: Polymorphism) Using an abstract class with only pure virtual functions, you can specify similar behaviors for possibly.
Explore types of principal-agency relationships : Explore types of principal-agency relationships and determine what type of relationship exists in this case between the driver, Jose Carcamo, and the company.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Why does mysql also use the sql start transaction statement

Explain the use of the SQL BEGIN TRANSACTION, COMMIT TRANSACTION, and ROLLBACK TRANSACTION statements. Why does MySQL also use the SQL START TRANSACTION statement?

  What is the effect of pressing the various i arrow keys

Develop additional techniques for manipulating and accessing controls placed on a form.

  Write a public method called handletwoarrays

Q3.  Write a public method called handleTwoArrays that accepts two integer arrays (assuming they are of same sizes) as parameters. The method invokes switchTwoArrays to perform switching if the sum of the values in the first array is smaller than the..

  Equation of the line that passes through

Write the equation of the line that passes through (1,1) and has the slope of 1 in point-slope form.

  Given two variables is_empty which is associated with a bool

Given two variables is_empty which is associated with a bool

  Self-mappings of ihi

Prove that if a linear fractional transformation w = (az + b) / ( cz + d) maps the real line of the z plane into the real line of the w plane, then a , b, c, and d must all be real, except possibly for a common phase factor that can be remov..

  Design pseudocode for the image comparison algorithm

Design an algorithm (using pseudocode) that takes in as an input, two 2-D int arrays that are assumed to be 2 black-and-white images: initialImage x, whose dimensions are IxJ, and finalImage y, whose dimensions are IxK. The algorithm will compare ..

  Meyers-briggs type indicator personality inventory

What is the Meyers-Briggs Type Indicator personality inventory, and why is it a useful tool for healthcare executives? Describe why human resources management is comprised of strategic and administrative actions.

  How are the retentive timer and reset instruction related

When does the rung of a TOF timer begin accumulating time?

  Consequences of experiencing a negative burn rate

What is a founders' agreement and why is it important for a team of entrepreneurs to have one in place when launching a venture? What is meant by the term "Burn rate"? What are the consequences of experiencing a negative burn rate for a relatively ..

  What is the forecasted dividend

Draw the time line of the stock's CFs? What is the forecasted dividend for each of the next 2 years (D1 and D2)? What is the forecasted dividend 3 years from now?

  Write a natural language parser that uses a dynamic database

Natural language parsing and databases. For this exercise, combine the techniques of sections 9.4 and 9.6 to build a natural language parser with a large vocabulary that can be updated at run time. In other words, write a natural language parser t..

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