Welcome to Westonci.ca, where curiosity meets expertise. Ask any question and receive fast, accurate answers from our knowledgeable community. Find reliable answers to your questions from a wide community of knowledgeable 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;
}
We appreciate your time. Please come back anytime for the latest information and answers to your questions. We hope our answers were useful. Return anytime for more information and answers to any other questions you have. Thank you for visiting Westonci.ca. Stay informed by coming back for more detailed answers.