Language (or Software): C++
This lab introduces you to writing a C++ program to implement the concept of class inheritance using different types of bank accounts as a model. In this lab, you will create a base class, called CBankAccount, and two additional classes (each derived from CBankAccount), called CSavingsAccount and CCheckingAccount. You will then test the operations of each class in function main() to simulate the transactions of both a checking account and a savings account.
STEP 1: Create the Multifile Project and the Main (Base) Class
Create a new project that consists of the base class BankAccount.
The BankAccount class should contain, at minimum, the following members.
It should contain data members to store a bank customer’s balance and account number. These should be of different and appropriate data types.
It should have function members that do the following:
set the account number;
return the account number;
return the account balance;
deposit money into the account; and
withdraw money from the account.
STEP 2: Create the CheckingAccount Class Derived From the BankAccount Class
The class CheckingAccount should contain, at a minimum, the following members.
It should contain a data member to keep track of the number of withdrawal transactions made on the account. Whenever a withdrawal is made, this number should be incremented.
Override the base class, withdraw-money function, and add the capability to deduct transaction fees from an account using the following guidelines.
The checking account is allowed three free transactions. For each successful withdrawal transaction past the three free transactions, there will be a service fee of 50 cents per transaction. The service fee should be deducted from the account balance at the time the transaction is made.
If there are insufficient funds in the account balance to cover the withdrawal plus the service fee, the withdrawal should be denied.
The function should return a value to indicate whether the transaction succeeded or failed. Transaction fees should be deducted only from successful transactions, but the transaction count should be incremented in either case.
STEP 3: Create the SavingsingAccount Class Derived From the BankAccount Class
The class CheckingAccount should contain, at a minimum, the following members.
It should contain a data member to hold the daily interest rate. The daily interest rate can be calculated from a yearly interest rate by dividing the annual rate by 365.
It should contain a data member to keep track of the number of days since the last transaction or balance inquiry. This should be updated using a random-number generator (reference Lab 1) that will return a value representing the number of days between 0 and 7, inclusive. We will assume that this bank is open every day of the year.
It should contain a data member to hold the interest earned since the last transaction or balance inquiry.
It should contain a function member to set the annual interest rate.
Utilize the base-class functions for both withdrawal and deposit operations for the savings account.
Override the base-class-balance inquiry function to add calculating and adding interest to the account based on the daily interest rate, the current balance of the account, and the number of days since the last balance inquiry. This should be called only when a balance inquiry is made, not when a deposit or withdrawal transaction or an account number inquiry is made.
If there are insufficient funds in the account balance to cover a withdrawal, the withdrawal should be denied. The number of days since the last transaction or balance inquiry and the interest calculations should still be made.
A value should be returned to indicate whether a withdrawal transaction succeeded or failed.
It should contain a function member to return the interest earned since the last transaction or balance inquiry.
It should contain a function member to return the number of days since the last transaction or balance inquiry.
STEP 4: Test Program Operation
All data-input and data-display operations (cin and cout) should be done in the function main() test program.
The test program should create one checking account and one savings account with initial balances of $100 each using the functions defined in the class definitions. The test program should also assign a unique, five-digit account number to each account and assign an annual interest rate of 3% for the savings account.
The test program should then display a menu that allows the user to select which option is to be performed on which account, including the following.
Make a deposit and specify the amount to a selected or an entered account.
Make a withdrawal and specify the amount to a selected or an entered account.
Return the balance of a selected or an entered account.
For deposit transactions, withdrawal transactions, and balance inquiries, the updated balance and any fees charged or interest earned should also be displayed.
For the savings account, the number of days since last transaction should be displayed.
Exit the program.
Each account operation should display the account number and the account type.
Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.
You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.
Read moreEach paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.
Read moreThanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.
Read moreYour email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.
Read moreBy sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.
Read more