Word 7-dt-content-rid-10730367-1/courses/17 608.2018 30/Lab%20Assignment%20%283-
ID: 3699034 • Letter: W
Question
Word 7-dt-content-rid-10730367-1/courses/17 608.2018 30/Lab%20Assignment%20%283-29-ise par Lab Assignment (Classes & OOP) Bank Account Due Monday, April 2d @11:59pm Write a program 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_Withdrawall), 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 anount of funds in your checking account is: $5e00.88 Please enter the amount of funds to deposit into your checking account: 52555 The eurrent balance of your checking account is: $5525.55 Please enter The current balance of your checking account is: $5899.99 the anount of funds to withdraw from your checking account: $425.56Explanation / Answer
#include <iostream>
using namespace std;
class BankAccount // class
{
private:
//private variable
double balance;
public:
//public methods
void setInitial_Amount(double balance)
{
this->balance = balance;
}
void make_Deposit(double amount)
{
balance = balance + amount;
}
void make_Withdrawal(double amount)
{
balance = balance - amount;
}
double getBalance()
{
return balance;
}
};
int main() {
BankAccount b; // object of class BankAccount
double initialAmount,deposit,withdraw;
cin>>initialAmount;
b.setInitial_Amount(initialAmount);
cout<<"The initial amount of funds in your checking account is :$"<<b.getBalance();
cout<<" Please enter the amount of funds to deposit in your checking account :";
cin>>deposit;
b.make_Deposit(deposit);
cout<<" The current balance of your checking account is :$";
cout<<b.getBalance();
cout<<" Please enter the amount of funds to withdraw from your checking account : ";
cin>>withdraw;
b.make_Withdrawal(withdraw);
cout<<" The current balance of your checking account is : $";
cout<<b.getBalance();
return 0;
}
Output:
The initial amount of funds in your checking account is :$5000
Please enter the amount of funds to deposit in 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 : $5099.99
Do ask if any doubt. Please upvote.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.