Answer:
here you go ,could only do Question 2.try posting question 1 seperately maybe someone else can also try to help
Explanation:
Question 2.
#include <iostream>
using namespace std;
// class BankAccount
class BankAccount{
// instance variables
private:
int accountID;
int balance;
public:
// constructor
BankAccount(int accountID, int balance){
this->accountID = accountID;
this->balance = balance;
}
// getters and setters
void setAccoutnId(int accountID){
this->accountID = accountID;
}
int getAccountId(){
return accountID;
}
void setBalance(int balance){
this->balance = balance;
}
int balanceInquiry(){
return balance;
}
};
class CurrentAccount : public BankAccount{
public:
// constructor
CurrentAccount(int accountID, int balance):BankAccount(accountID,balance){
}
// function amount to withdraw
void amountWithdrawn(int amount){
setBalance(balanceInquiry()-amount);
}
// function to deposit amount
void amountDeposit(int amount){
setBalance(balanceInquiry()+amount);
}
};
class SavingsAccount : public BankAccount{
public:
// constructor
SavingsAccount(int accountID, int balance):BankAccount(accountID,balance){
}
// function amount to withdraw
void amountWithdrawn(int amount){
setBalance(balanceInquiry()-amount);
}
// function to deposit amount
void amountDeposit(int amount){
setBalance(balanceInquiry()+amount);
}
};
int main()
{
// calling function of Current Account
cout<<"Current Account : "<<endl;
CurrentAccount current(122,100000);
current.amountWithdrawn(10000);
cout<<"Your balance after withdraw : ";
cout<<current.balanceInquiry()<<endl;
current.amountDeposit(30000);
cout<<"Your balance after deposit : ";
cout<<current.balanceInquiry()<<endl;
cout<<endl<<endl;
// calling function of Savings Account
cout<<"Savings Account : "<<endl;
SavingsAccount saving(125,80000);
saving.amountWithdrawn(5000);
cout<<"Your balance after withdraw : ";
cout<<saving.balanceInquiry()<<endl;
saving.amountDeposit(20000);
cout<<"Your balance after deposit : ";
cout<<saving.balanceInquiry();
return 0;
}