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

Write a program containing a for loop

SCSC011 PRACTICALS: C++ PROGRAMMING ASSIGNMENT. Write a program containing a for loop (going from 1 to 50) where the answer (1, 2 or 3) of each respondent to each question is

Write a c program that asks user to enter a time

Write a C program that asks user to enter a time (expressed in hours and minutes, using 24-hour clock). The program then displays the flight schedule whose departure time is

Different ways to represent a birthday register

Describe two different ways to represent a birthday register, i.e. the names of your friends and their birth dates. Assume that none of your friends have the same name, but

Write definitions of the functions to overload the operators

Write the definitions of the functions to overload the operators defined in parts a to c and write  a  test  program  that  tests  various  operations  on  the class rectangle

Write a c program that solve specific problem in their field

The second option is for the students to write a "C" program that solve a specific problem in their field. The students must get the approval from the instructor before they

Compound and nested if statements

Compound and Nested If Statements- Suggest one (1) example of a problematic programming situation or scenario that the use or implementation of a compound if statement could

Write a program that reads a collection of positive numbers

Write a program that reads a collection of positive and negative numbers and multiplies only the positive integers. Loop exit should occur when three consecutive negative val

Wave steepness is the ratio of wave height

Wave steepness is the ratio of wave height (WH) to wave length(WL) and is an indicator of wave stability. When wave steepness exceeds a 1/7 ratio; the wave becomes unstable

Reviews

Write a Review

 
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