Question: In the following C++ code, Add three at least additional functions (services/options you have available or imagine when you use the ATM machine or a
In the following C++ code, Add three at least additional functions (services/options you have available or imagine when you use the ATM machine or a bank with a cashier).
#include
double transaction; double currentBalance (5000);
char pickTransaction(void); void message (void); void deposit(void); void withdraw(void);
// This code only perform one transaction. Modify it to give the user opportunity to perform as many operations as she/he desires. int main() { cout << " Welcome to Your Bank! " << endl; char letter = pickTransaction(); if ((letter == 'D') || (letter == 'd')) { deposit(); } if ((letter == 'W') || (letter == 'w')) { withdraw(); } if ((letter == 'B') || (letter == 'b')) { message(); } system ("pause"); return 0; }
char pickTransaction() { char input; do { cout << "What transaction would you like to perform today? Enter D for Deposit, W for Withdraw, or B to see your Balance "; cin >> input; } while ((input != 'B') && (input != 'b') && (input != 'W') && (input != 'w')&& (input != 'D')&& (input != 'd')); return input; }
void message (void) { cout << " your new balance is: $" << currentBalance << endl; }
void deposit(void) { cout << "How much do you want to deposit? "; cin >> transaction; currentBalance = currentBalance + transaction; message(); }
void withdraw(void) { cout << "How much do you want to withdraw? "; cin >> transaction; if (currentBalance <=0) {cout << " Your balance is low; transaction cannot be performed. ";} else {currentBalance = currentBalance - transaction;} message();
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
