Describe about the account inheritance hierarchy

Assignment Help Basic Computer Science
Reference no: EM131610255

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.

Reference no: EM131610255

Questions Cloud

Discuss about the personal key performance indicators : Using Porter's Five Forces Model, personal Critical Success Factors (CSFs) and/ personal Key Performance Indicators (KPIs).
Write test program that creates objects of each type package : (Package Inheritance Hierarchy) Package-delivery services, such as FedEx®, DHL® and UPS®, offer a number of different shipping options.
How public officers enforce the laws for private companies : How can public officers enforce the laws for private companies without creating a conflict of interest
Define the requirements of human service workers : Review your state's law or administrative rule regarding informed consent and the requirements of human service workers
Describe about the 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).
Why are tribunals very important among two or more countries : Why are tribunals very important among two or more countries. How can the cultural and political differences that exist between nations affect a tribunal
Fault tolerant network design : Explain three (3) approaches that network administrators can use in order to ensure a fault tolerant network design without a single point of failure.
Discuss the key advantages of programming in the general : (Programming in the General) How is it that polymorphism enables you to program "in the general" rather than "in the specific"?
Discuss community policing strategies and potential changes : What are some of the current community policing strategies and potential changes

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Identifies the cost of computer

identifies the cost of computer components to configure a computer system (including all peripheral devices where needed) for use in one of the following four situations:

  Input devices

Compare how the gestures data is generated and represented for interpretation in each of the following input devices. In your comparison, consider the data formats (radio waves, electrical signal, sound, etc.), device drivers, operating systems suppo..

  Cores on computer systems

Assignment : Cores on Computer Systems:  Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency, and packaging form factors.

  Prepare an annual budget in an excel spreadsheet

Prepare working solutions in Excel that will manage the annual budget

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Describe the forest, domain, ou, and trust configuration

Describe the forest, domain, OU, and trust configuration for Bluesky. Include a chart or diagram of the current configuration. Currently Bluesky has a single domain and default OU structure.

  Construct a truth table for the boolean expression

Construct a truth table for the Boolean expressions ABC + A'B'C' ABC + AB'C' + A'B'C' A(BC' + B'C)

  Evaluate the cost of materials

Evaluate the cost of materials

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Describe the three fundamental models of distributed systems

Explain the two approaches to packet delivery by the network layer in Distributed Systems. Describe the three fundamental models of Distributed Systems

  Distinguish between caching and buffering

Distinguish between caching and buffering The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of failure. Give one type of failure with a brief description of the failure

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