steamengines

Chapter 7

Oct 8th, 2014
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.26 KB | None | 0 0
  1. //Christian Ballard
  2. //COSC 1330 - 003
  3. //This program will set a menu for a bank.
  4. #include <iostream>
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     cout << "Welcome to Drew's Bank!" << endl;
  10.     cout << endl;
  11.     //Variables
  12.     float balance = 0.0;
  13.     char response = ' ';
  14.     const int NSF = 35;
  15.     float checkValue = 0.0;
  16.     float deposit = 0.0;
  17.     float chargeValue = 0.0;
  18.  
  19.     //find out the users balace
  20.     cout << "What is your current balance? " << endl << "$";
  21.     cin >> balance;
  22.     //Clear the screen
  23.     system("CLS");
  24.     //Bank menu
  25.     cout << "What would you like to do?" << endl;
  26.     cout << endl;
  27.     cout << "For a check, please enter the number '1'" << endl << "For a deposit, please enter the number '2'" << endl << "For a charge, please enter the number '3'" << endl;
  28.     cin >> response;
  29.     system("CLS");
  30.     //Switch statement
  31.     switch (response)
  32.     {
  33.     case '1':
  34.         cout << "You have chosen the check option." << endl << endl;
  35.         cout << "What is the value of the check?" << endl << "$";
  36.         cin >> checkValue;
  37.         system("CLS");
  38.         if (checkValue <= balance)
  39.         {
  40.             balance = balance - checkValue;
  41.             cout << "You have withdrawn $" << checkValue << endl << "Your new balance is $" << balance << endl;
  42.         }
  43.         else
  44.         {
  45.             cout << "You have insufficient funds, an NSF charge of $35.00 has been added to your account." << endl;
  46.             balance = balance - NSF;
  47.             cout << "Your new balance is $" << balance << endl;
  48.         }
  49.         break;
  50.     case '2':
  51.         cout << "You have chosen to make a deposit." << endl << endl;
  52.         cout << "How much would you like to deposit?" << "$" << endl;
  53.         cin >> deposit;
  54.         balance = deposit + balance;
  55.         cout << "Your new current balance is." << endl << "$" << balance << endl;
  56.         break;
  57.     case '3':
  58.         cout << "You have chosen to make a charge on your account." << endl;
  59.         cout << endl << "What is the value of the charge?" << endl << "$";
  60.         cin >> chargeValue;
  61.         if (chargeValue > balance)
  62.         {
  63.             cout << "Insufficient funds, card denied." << endl;
  64.         }
  65.         else
  66.         {
  67.             balance = balance - chargeValue;
  68.             cout << "Your new current balance is" << endl << "$" << balance << endl;
  69.         }
  70.         break;
  71.     default:
  72.         response = 'z';
  73.     }
  74.  
  75.     if (response == 'z')
  76.     {
  77.         cout << "Please enter '1' for a check, '2' for a deposit, or '3' for a charge. " << endl;
  78.     }
  79.  
  80.  
  81.  
  82.  
  83.     system("pause");
  84.     return 0;
  85. }
Advertisement
Add Comment
Please, Sign In to add comment