Discover the best answers at Westonci.ca, where experts share their insights and knowledge with you. Discover in-depth answers to your questions from a wide network of experts on our user-friendly Q&A platform. Join our platform to connect with experts ready to provide precise answers to your questions in different areas.
Sagot :
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;
}
Thanks for stopping by. We strive to provide the best answers for all your questions. See you again soon. We appreciate your visit. Our platform is always here to offer accurate and reliable answers. Return anytime. We're glad you chose Westonci.ca. Revisit us for updated answers from our knowledgeable team.