Write a program that creates a class named BankAccount, that possesses one data
ID: 3698900 • Letter: W
Question
Write a program that creates a class named BankAccount, that possesses one data attribute named, balance. The methods for this class should consist of setinltial_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. If written correctly, your program should resemble the following: The initial amount of funds in your checking account is: s5000.ee Please enter the amount of funds to deposit into your checking account: $525.55 The current balance of your checking account is: $5525.55 Please enter the amount of funds to withdraw from your checking account: $425.56 The current balance of your checking account is: s5899.99Explanation / Answer
Please find my implementation:
#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:
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.