Inherit 4

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

#include<iostream>

using namespace std;


class Account {
protected:
double balance;
public:
Account() {
balance = 00;
}
Account(double balance1) {
balance = balance1;
}
void setBalance(double balance1) {
balance = balance1;
}
int getBalance() {
return balance ;
}

void withDraw(double amount1) {


if (amount1 > balance) {
cout << "Insufficient balance" << endl;
}
else {
balance = balance - amount1;
cout << "Withdrawn succesfully" << endl;
}

}
void Deposit(double amount1) {
balance += amount1;
cout << "Balance is deposited succesfuuly" << endl;
}

};

class SavingsAccount :public Account {


private:
double InterestRate;
public:
SavingsAccount() {
InterestRate = 0;
}
SavingsAccount(double InterestRate1) {
InterestRate = InterestRate1;
}
int getInterest() {
return InterestRate;
}
void setInterest(double InterestRate1) {
InterestRate = InterestRate1;
}
void calculateInterest() {
cout << "The interest Rate is \t" << balance * (InterestRate / 100);
cout << endl;
}
};
int main() {
SavingsAccount a1;
a1.setInterest(12);
a1.setBalance(200);
a1.withDraw(100);
a1.Deposit(200);
a1.calculateInterest();
return 0;
}

You might also like