Advertisement
Guest User

colin switch

a guest
Apr 28th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.05 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <iomanip>
  4.  
  5. using namespace std;
  6.  
  7.  
  8. int main()
  9. {
  10.     cout << "--Welcome to ICS Simple Cashier--";
  11.     cout << "\n\nPlease enter an 'a' fro apples or an 'o' for oranges: ";
  12.  
  13.     char fruit = '\0';  //what fruit
  14.     float price = 0.f;  //said fruit price
  15.  
  16.     string item = ""; // string for each fruit called item
  17.     cin >> fruit;
  18.     cin.ignore(1000, '\n');
  19.  
  20.     if (fruit == 'a')  //if user wants apples
  21.     {
  22.         price = 0.50f;   //price of apples
  23.         item = "Apples";
  24.         {
  25.             cout << "\nHow many apples do you wish to buy: ";  //ask user how many he/she wants
  26.             int numA = 0;    //number of fruit
  27.             cin >> numA;
  28.             cout << "\nYou want to buy " << numA << " apple(s).";
  29.             {
  30.                 if (numA < 1 || numA > 20)    //error correction range from 1 to 20
  31.                     cout << "Please enter a valid # of apples between 1 and 20.";
  32.                 {
  33.                     cout << "\n\nItem     Qty     Price     Total";   //output cashier screen thing
  34.                     cout << "\n--------------------------------";
  35.                     cout << setprecision(2) << fixed << "\nApples    " << numA << "      $" << price << "    $" << numA * price;
  36.                     cout << "\nTax(15%): $" << numA * price * 0.15f << "\n";
  37.                     cout << "Total Cost: $" << numA * price * 1.15f;
  38.                     {
  39.                         cout << "\n\nHow much money are you buying with?  ";
  40.                         int money = 0;
  41.                         cin >> money;
  42.                         cin.ignore();
  43.                         if (money >= numA*price*1.15f && money <= 100)
  44.                         {
  45.                             cout << "\n-----------------";
  46.                             cout << "\nAmount Tendered: $" << money;
  47.                             cout << "\nChange: $" << money - numA*price*1.15f;
  48.                         }
  49.                             else if (money > 100)
  50.                         {
  51.                                 cout << "\nSorry, there is not enough change in the till for that amount";
  52.                                 return 0;
  53.                         }
  54.                             else (money < 0.575);
  55.                         {
  56.                                 cout << "\nSorry, that is not enough for your purchase.";
  57.                                 return 0;
  58.                         }
  59.  
  60.                     }
  61.                 }
  62.             }
  63.         }
  64.     }
  65.     else if (fruit == 'o')
  66.     {
  67.         price = 0.75f;
  68.         item = "Oranges";
  69.     }
  70.     else
  71.     {
  72.         cout << "\n\nYou did not type in a valid fruit";
  73.         return 0;
  74.     }
  75.    
  76.  
  77.  
  78.    
  79.  
  80.  
  81.  
  82.    
  83.    
  84.    
  85.    
  86.     return 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement