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

Please do in C++ and this is all the information 1. BankAccount.cpp file code 2.

ID: 3722269 • Letter: P

Question

Please do in C++ and this is all the information

1. BankAccount.cpp file code

2. Bankaccount.h file

Files you will be submitting: 8B_BankTell.cpp with output
Notes: Remember to add your information to output and copy and paste output to the bottom of the main program
Points: 10

General Directions:

You will be writing 8B_BankTeller.cpp from scratch. Make sure you place all 3 files in the project folder on your hard drive.

Download (replace if necessary) BankAccount.h and BankAccount.cpp files that are attached above and place them in your project folder.

In your assignment file, include, be sure to: #include "BankAccount.h", <iostream>, and <string>

Create some local variables store name and starting balance and pass thosevalues to a new object of BankAccount.

Use the BankAccount class to store and retrieve name and balance.

Create a menu system that will have a post-condition do-while loop that will loop until choice (choice is a char) = "Q". Use toupper on choice so it will accept upper or lower case characters.

W)ithdraw, D)eposit, or Q)uit:

Use a switch statement with cases 'W', 'D', or 'Q' to withdraw, deposit, or quit. Include a default that will return a error (option not available).

Note that BankAccount class will return an error that you can use if you try to withdraw too much.

On exiting your program, report the balance.

Please mimic the following output for your output.

Output:

/*

Student Name, CIS127, Assignment 8.1

Enter customer name: Thomas DeJong
Enter initial balance: 0

W)ithdraw, D)eposit, or Q)uit: d
Enter deposit amount: 250

W)ithdraw, D)eposit, or Q)uit: w
Enter withdrawal amount: 300
ERROR: Cannot withdraw 300 since current balance is 250

W)ithdraw, D)eposit, or Q)uit: w
Enter withdrawal amount: 200

W)ithdraw, D)eposit, or Q)uit: q
Thank you for your business Thomas DeJong
Ending balance: 50

Press any key to continue . . .
*/

Explanation / Answer

/* BankAccount,cpp*/


#include "BankAccount.h"
#include <iostream>
#include <string>
using namespace std;

BankAccount::BankAccount(string pName, double pCurrentBalance)
{
name = pName;
balance = pCurrentBalance;
}

BankAccount::BankAccount()
{
balance = 0;
name = "No Name";
}

void BankAccount::deposit(double amount)
{
balance += amount;
}

void BankAccount::withdraw(double amount)
{
if (balance >= amount)
{
balance -= amount;
}
else
{
std::cout << "ERROR: Cannot withdraw " << amount << " since current balance is " << balance << std::endl;
}
}

int BankAccount::getBalance()
{
return balance;
}

string BankAccount::getName() {
return name;
}
int main()
{
char choice;
std::string name;
double balance;
cout<<"Enter customer name:";
cin>>name;
cout<<"Enter initial balance:";
cin>>balance;
BankAccount* b1=new BankAccount(name,balance);
do{
cout<<"W)ithdraw, D)eposit, or Q)uit:";
cin>>choice;
choice=toupper(choice);
if(choice=='W')
{
cout<<"Enter withdrawal amount: ";
cin>>balance;
b1->withdraw(balance);
}
else
if(choice=='D')
{
cout<<"Enter deposit amount:";
cin>>balance;
b1->deposit(balance);
}
else if(choice!='Q')
{
cout<<" Error: Invalid choice...";
}
  
}while(choice!='Q');
  
return 0;
}

/*output

Enter customer name:pavan
Enter initial balance:50
W)ithdraw, D)eposit, or Q)uit:w
Enter withdrawal amount: 100
ERROR: Cannot withdraw 100 since current balance is 50
W)ithdraw, D)eposit, or Q)uit:d
Enter deposit amount:500
W)ithdraw, D)eposit, or Q)uit:w
Enter withdrawal amount: 500
W)ithdraw, D)eposit, or Q)uit:k

Error: Invalid choice...W)ithdraw, D)eposit, or Q)uit:q

*/