Question
please please please help me. use c++ and show your output In this assignment, you will utilize the BankAccount class that we created in the
please please please help me. use c++ and show your output
In this assignment, you will utilize the BankAccount class that we created in the class and define two child classes named Savings and Checking, respectively and apply polymorphism by meeting the following requirements.
R1: Account class
We will modify the BankAccount class as below
Member variables
Change double balance to double* balance;
Change double interestRate to double* interestRate;
Add a static member named count whose role is to keep track of the number of bank accounts that have been created.
By doing the first two lines, your program stores the values of balance and interestRate in the heap.
Add three member functions below
void deposit(double);
void withdraw(double);
static int getAccount();
Add the const keyword to each getter
Add the update() as a pure virtual function as below.
virtual void update() = 0;
Notice that the destructor is a virtual function
R2: Checking class
Implement the update() by applying the annual interest rate of 1.5% on the balances over $1000
R3: Savings class
Implement the update() by applying the annual interest rate of 3% on any balance.
R4. Test program
In your main(), you will demonstrate how polymorphism in C++ is implemented and tested. You need to find a way to implement the requirements below using polymorphism.
Using a loop or loops, create three savings and three checking accounts using the following balances in the heap.
Account | Initial Balance |
Savings#1 | $500.50 |
Savings#2 | $700.70 |
Savings#3 | $900.90 |
Checking#1 | $200.10 |
Checking#2 | $400.30 |
Checking#3 | $600.60 |
In each year for five years, apply three times a deposit of $300 and a withdrawal of $150.50 for all bank accounts as long as withdrawal is valid. If the balance is 0 and withdrawal occurs, displays "Invalid withdrawal", though this will not happen in our program. Also, apply the annual interest rate at the end of each year.
At the end of the fifth year, display the number of accounts and the balance of each account.
Account.h
#ifndef ACCOUNT_H
#define ACCOUNT_H
class Account
{
private:
double balance;
double interestRate;
public:
Account();
Account(double);
virtual ~Account();
double getBalance();
void setBalance(double);
void print() ;
};
#endif
sample output
Add three member functions below
void deposit(double);
void withdraw(double);
static int getAccount();
Add the const keyword to each getter
Add the update() as a pure virtual function as below.
virtual void update() = 0;
Notice that the destructor is a virtual function
R2: Checking class
Implement the update() by applying the annual interest rate of 1.5% on the balances over $1000
R3: Savings class
Implement the update() by applying the annual interest rate of 3% on any balance.
R4. Test program
In your main(), you will demonstrate how polymorphism in C++ is implemented and tested. You need to find a way to implement the requirements below using polymorphism.
Using a loop or loops, create three savings and three checking accounts using the following balances in the heap.
Account | Initial Balance |
Savings#1 | $500.50 |
Savings#2 | $700.70 |
Savings#3 | $900.90 |
Checking#1 | $200.10 |
Checking#2 | $400.30 |
Checking#3 | $600.60 |
In each year for five years, apply three times a deposit of $300 and a withdrawal of $150.50 for all bank accounts as long as withdrawal is valid. If the balance is 0 and withdrawal occurs, displays "Invalid withdrawal", though this will not happen in our program. Also, apply the annual interest rate at the end of each year.
At the end of the fifth year, display the number of accounts and the balance of each account.
Account.h
#ifndef ACCOUNT_H
#define ACCOUNT_H
class Account
{
private:
double balance;
double interestRate;
public:
Account();
Account(double);
virtual ~Account();
double getBalance();
void setBalance(double);
void print() ;
};
#endif
sample output
At the end of the 5th year
Number of account: 6
Saving#1: 3041.00
Saving#2: 3273.09
Saving#3: 3505.17
Checking#1: 2559.15
Checking#2: 2771.63
Checking#3: 3000.85
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started