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

Write a C++ program that asks the user to enter 5 addtional functions to the cod

ID: 3686077 • Letter: W

Question

Write a C++ program that asks the user to enter 5 addtional functions to the code below: (services/options you have available when you use the ATM machine can be the functions used on this code ).

#include
using namespace std;

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();
}

Explanation / Answer

#include
using namespace std;

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;
while(true)

{
     char letter = pickTransaction();

/*Alternative way with out pick transaction function

cout<<"Enter   D     or   d for Deposit "<<endl;

cout<<"Enter   W or   w for Withdraw "<<endl;

cout<<"Enter   B    or   b for message "<<endl;

cout<<"Enter   E     or   e for Exit"<<endl;*/


   if ((letter == 'D') || (letter == 'd'))
   {
       deposit();
   }
   if ((letter == 'W') || (letter == 'w'))
   {
       withdraw();
   }
   if ((letter == 'B') || (letter == 'b'))
   {
       message();
   }

if ((letter == 'E') || (letter == 'e'))
   {
       return true;
   }

   system("pause");
   return 0;
}

}//while

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 E for Exit ";
       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 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();
}//main

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote