Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ PROGRAMMING LANGUAGE Create the savingsAccount class via Inheritance Using I

ID: 3880721 • Letter: C

Question

C++ PROGRAMMING LANGUAGE

Create the savingsAccount class via Inheritance

Using Inheritance, create class savingsAccount by deriving from the class bankAccount used in Part 1

A person with a savingsAccount has the following:

a.An account number

b.A balance amount

c.Interest rate

Note that part (a) and (b) are obtained via Inheritance from the parent class. Hence only part (c) will be data membes in the savingsAccount class

The following functions should be defined in this class:

a.Set interest rate

b.Retrieve interest rate

c.Withdraw amount from balance and it should be an override to check to ensure there is enough money.

d.Post interest. That is, update the balance with the amount of interest which is obtained by multiplying the interest rate with current balance and then update this amount to the existing balance.

e.Override the print() function to show that it is a Saving account #. Same information printed but only modify the description.

f.Appropriate constructor to accept account number, balance and interest rate.

Write a test program to test only this savingsAccount class

Explanation / Answer

here is your program : ------------------->>>>>>>>>>>>>>

#include<iostream>

using namespace std;

class bankAccount{

protected:

double balance;

int acNo;

public:

bankAccount(int ac,double balance){

this->balance = balance;

this->acNo = ac;

}

double getBalance(){

return balance;

}

int getAccount(){

return acNo;

}

void setBalnace(double amount){

balance = amount;

}

void withdraw(double amount){

balance = balance - amount;

}

void deposit(double amount){

balance = balance + amount;

}

void print(){

cout<<" Account Number : "<<acNo<<" Balnace : "<<balance;

}

};

class SavingAccount:public bankAccount{

int interestRate;

public:

SavingAccount(double bal,int ac,int rate):bankAccount(ac,bal){

interestRate = rate;

}

void setInterestRate(int rate){

interestRate = rate;

}

int getInterestRate(){

return interestRate;

}

void update(){

setBalnace(getBalance()+(getBalance()*interestRate/100));

}

void withdraw(int amount){

if(amount < getBalance()){

setBalnace(getBalance()-amount);

}

}

void print(){

cout<<" Account Type : SavingAccount ";

cout<<" Account Number : "<<getAccount()<<" Balnace : "<<getBalance();

}

};

int main(){

SavingAccount s1(4000,123,5);

s1.print();

s1.withdraw(200);

s1.print();

s1.update();

s1.print();

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote