Add five additional functions to buttom code to print on C++ program? #include u
ID: 3686044 • Letter: A
Question
Add five additional functions to buttom code to print on C++ program? #include using namespace std; double transaction; double currentBalance (5000); char pickTransaction(void); void message (void); void deposit(void); void withdraw(void); 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(); }
Explanation / Answer
//I ASSUME YOU WANT TO MAKE A MENU DRIVEN PROGRAM OUT OF THIS
#include <iostream>
using namespace std;
double transaction;
double currentBalance (5000);
char pickTransaction(void);
void message (void);
void deposit(void);
void withdraw(void);
int main()
{
while(true)
{
cout << " -----------Welcome to Your Bank!------------ " << endl;
char letter = pickTransaction();
if ((letter == 'D') || (letter == 'd'))
{
deposit();
}
else if ((letter == 'W') || (letter == 'w'))
{
withdraw();
}
else if ((letter == 'B') || (letter == 'b'))
{
message();
}
else if((letter=='E') || (letter=='e'))
{
break;
}
}
system ("pause");
return 0;
}
char pickTransaction()
{
char input;
do {
cout << "What transaction would you like to perform today? Enter D: Deposit Enter W: Withdraw Enter B: Current Balance Enter E: Exit Your choice: ";
cin >> input;
}
while ((input != 'B') && (input != 'b') && (input != 'W') && (input != 'w')&& (input != 'D')&& (input != 'd') && (input != 'E')&& (input != 'e'));
return input;
}
void message (void)
{
cout << "Your Current 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();
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.