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

Write a program in C++ that creates a class named BankAccount, that possesses on

ID: 3740230 • Letter: W

Question

Write a program in C++ that creates a class named BankAccount, that possesses one data attribute named, balance. The methods for this class should consist of setInitial_Amount(), make_Deposit(), make_Withdrawal(), and getBalance(). (Note: the make_Deposit and make_Withdrawal methods should also be treated like a set or mutator function.) The balance should be initialized to $5,000.00. Afterwards, the user should be prompted for the amount to deposit into account. Next, the user should be prompted for the amount to be withdrawn from the account. The current balance should be displayed after each transaction including the initial amount placed into the account.

Explanation / Answer

#include <iostream>

using namespace std;
class BankAccount {
private:
double balance;
public:
BankAccount() {
setInitial_Amount() ;
}
void setInitial_Amount() {
balance = 5000;

}
void make_Deposit(double d){
balance+=d;
}
void make_Withdrawal(double w){
balance-=w;
}
double getBalance() {
return balance;
}
};
int main()
{
double balance;
BankAccount b;
cout<<"Initial balance: "<<b.getBalance()<<endl;
cout << "Enter the amount to be deposited:" << endl;
cin >> balance;
b.make_Deposit(balance);
cout<<"Current balance: "<<b.getBalance()<<endl;
cout << "Enter the amount to be withdrawn:" << endl;
cin >> balance;
b.make_Withdrawal(balance);
cout<<"Current balance: "<<b.getBalance()<<endl;
return 0;
}

Output:

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