BankAccount Savings Credit Card CPP Solution

BankAccount Savings Credit Card CPP Solution

Concepts and Ideas

Objects and Classes – Inheritance

 

 

Assignment

            Start a console application called Bank that will contain three classes: BankAccount, then Savings and CreditCard.  Write a base class called BankAccount.  Remember that base classes aren’t complete, rather offer functionality to other derived classes.  The BankAccount class should have the following member variables and methods.

 

  1. Private Member Variables: mInterestRate, mPrincipal, mLastAccessTime

 

  1. Public Member Methods: float CalculateInterest(int Time), float GetInterestRate(), float GetPrincipal(), SetInterestRate(float IR), SetPrincipal(int Time, float Amount)

 

The Get and Set methods should be pretty obvious.  Assume that the amount entered for principal is in dollars.  Similarly, the interest rate is annual interest.  I used 12.0 to represent 12.0 percent annual interest (instead of 0.12).  CalculateInterest method calculates the amount of time passed and returns the interest earned.  Notice that time is simply an integer.  Time for a computer is usually a number that keeps increasing (usually in ms) from some set date and time.  To simplify this problem, assume time is in days and that the calling function will give you the time (in days).   Then the time passed (used to calculate interest) on will be: (Time – mLastAccessTime).

 

Once you get this class written and functional, generate another class that inherits the BankAccount class called Savings.  A savings account “is a” bank account.  Add the following methods to this class:

 

  1. void Deposit(int Time, float Amount) – If it is a new account, simply use the SetPrincipal() method from BankAccount.  If you have an existing account, then you need to add to the principal the interest earned and the deposit amount.

 

  1. bool Withdrawal(int Time, float Amount) – Check to see if the account has enough in it to make the withdrawal (remember the interest they’ve earned), then make the withdrawal.  If you make the withdrawal, return true, else return false.

 

  1. float GetBalance(int Time) – Simply returns the balance (including interest) of the account based on the time you send the function.

 

 

After you have Savings complete, generate another class like Savings Called CreditCard.  This class will also inherit from BankAccount and have the following methods:

 

  1. void Payment(int Time, float Amount) – decrease the balance after adding the interest.
  2. void SetCreditLimit(float Amount) – obvious, simply set the value.
  3. bool Charge(int Time, float Amount) – make sure to check to see if there is available credit before making the charge.  Return true is the charge is OK.  Return false if there isn’t sufficient available credit.
  4. float getAvailableCredit(int Time) – return the amount of available credit which involves the Principal and Interest.

To test and complete the project, use the supplied Bank.cpp file to test the classes.  The output should be exactly like (within a penny) of Bank.exe.  You know you’re done when your classes work like the example  Bank.exe.  Submit your project via Blackboard.

Place your order now with Reliablepapers.com
and experience the difference of letting the professionals do the work for you!
Our Process is Simple
Our Simple process

Order Now

Place Order