daily pastebin goal
49%
SHARE
TWEET

Untitled

a guest Oct 11th, 2018 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. #include <iostream>
  3. #include <iomanip>
  4. #include <fstream>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10.     ifstream file;
  11.     double checkingBalance, savingsBalance, amount;
  12.     int menu;
  13.     char choice;
  14.  
  15.     file.open("C:\\Users\\Michael\\Desktop\\college stuff\\CS Labs\\Lab5.txt"); //file path on my laptop
  16.     //file.open("S:\\mackay\\121-51\\Lab5data.txt"); file path at school
  17.     file >> savingsBalance >> checkingBalance;
  18.     file.close();
  19.    
  20.  
  21.     cout << "Please choose one of the following options: " << endl << endl;
  22.     cout << setw(4) << " " << "1: Deposit" << endl;
  23.     cout << setw(4) << " " << "2: Withdraw" << endl;
  24.     cout << setw(4) << " " << "3: Balance Inquiry" << endl;
  25.     cout << setw(4) << " " << "4: Transfer Money" << endl;
  26.  
  27.     cin >> menu;
  28.  
  29.     if (menu == 1)
  30.     {
  31.         cout << "Checking (C) or Savings (S)? ";
  32.         cin >> choice;
  33.         cout << "How much are you depositing? ";
  34.         cin >> amount;
  35.  
  36.         if (amount < 0)
  37.             cout << "input invalid";
  38.         else if (choice == 'C')
  39.         {
  40.             cout << "Your old balance was $" << checkingBalance;
  41.             checkingBalance = checkingBalance + amount;
  42.             cout << " and your new balance is $" << checkingBalance << endl;
  43.         }
  44.         else
  45.         {
  46.             cout << "Your old balance was $" << savingsBalance;
  47.             savingsBalance = savingsBalance + amount;
  48.             cout << " and your new balance is $" << savingsBalance << endl;
  49.         }
  50.     }
  51.  
  52.     else if (menu == 2)
  53.     {
  54.         cout << "Checking (C) or Savings (S)? ";
  55.         cin >> choice;
  56.         cout << "How much are you withdrawing? ";
  57.         cin >> amount;
  58.  
  59.         if (choice == 'C')
  60.         {
  61.             if (amount < 0 || amount > checkingBalance)
  62.                 cout << "input invalid";
  63.             else
  64.             {
  65.                 cout << "Your old balance was $" << checkingBalance;
  66.                 checkingBalance = checkingBalance - amount;
  67.                 cout << " and your new balance is $" << checkingBalance;
  68.             }
  69.         }
  70.         else
  71.         {
  72.             if (amount < 0 || amount > savingsBalance)
  73.                 cout << "input invalid";
  74.             else
  75.             {
  76.                 cout << "Your old balance was $" << savingsBalance;
  77.                 savingsBalance = savingsBalance - amount;
  78.                 cout << " and your new balance is $" << savingsBalance;
  79.             }
  80.         }
  81.     }
  82.  
  83.     else if (menu == 3)
  84.     {
  85.         cout << "Which account, checking (C) or savings (S)? ";
  86.         cin >> choice;
  87.  
  88.         if (choice == 'C')
  89.             cout << "Your balance is $" << checkingBalance;
  90.         else
  91.             cout << "Your Balance is $" << savingsBalance;
  92.     }
  93.  
  94.     else if (menu == 4)
  95.     {
  96.         cout << "(C) Checking to Savings? or" << endl << "(S) Savings to Checkings? ";
  97.         cin >> choice;
  98.         cout << "How much to transfer? ";
  99.         cin >> amount;
  100.         if (choice == 'C')
  101.         {
  102.             if (amount < 0 || amount > checkingBalance)
  103.                 cout << "invalid input";
  104.             else
  105.             {
  106.                 cout << "old balance for checking: $" << checkingBalance << endl;
  107.                 cout << "old balance for savings: $" << savingsBalance << endl;
  108.                 checkingBalance = checkingBalance - amount;
  109.                 savingsBalance = savingsBalance + amount;
  110.                 cout << "new balance for checking: $" << checkingBalance << endl;
  111.                 cout << "new balance for savings: $" << savingsBalance << endl;
  112.             }
  113.         }
  114.         else
  115.         {
  116.             if (amount < 0 || amount > savingsBalance)
  117.                 cout << "invalid input";
  118.             else
  119.             {
  120.                 cout << "old balance for checking: $" << checkingBalance << endl;
  121.                 cout << "old balance for savings: $" << savingsBalance << endl;
  122.                 checkingBalance = checkingBalance + amount;
  123.                 savingsBalance = savingsBalance - amount;
  124.                 cout << "new balance for checking: $" << checkingBalance << endl;
  125.                 cout << "new balance for savings: $" << savingsBalance << endl;
  126.             }
  127.         }
  128.     }
  129.  
  130.     else
  131.         cout << "invalid input";
  132.  
  133.     return 0;
  134. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top