Advertisement
Guest User

TSHIRT Program

a guest
Oct 18th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.28 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3.  
  4.     /*
  5.       Programmer: Bryan Virgil
  6.       Date:       10 04 2017
  7.       Description:    Tshirt company is giving the following discounts
  8.                         1..5   --> 0% discounts
  9.                         6..10  --> 10% discounts
  10.                         10+    --> 25% discounts*/
  11.  
  12. using namespace std;
  13.  
  14. int main()
  15. {
  16.  
  17.     int numTShirts;
  18.     cout << "How many T-Shirts did you purchase:";
  19.     cin >> numTShirts;
  20.     if (cin.fail())
  21.     {
  22.         cout << "Wrong data type, please run the program" << endl;
  23.     }
  24.     else
  25.     {
  26.         if (numTShirts < 1)
  27.         {
  28.             cout << "Invalid quantity, please run the program again" << endl;
  29.             cout << "Exiting..." << endl;
  30.             exit(EXIT_FAILURE);
  31.         }
  32.         // get rid of the exit and implement the else part
  33.        // else
  34.        switch(numTShirts)
  35.        {
  36.        case 1:
  37.        case 2:
  38.        case 3:
  39.        case 4:
  40.        case 5:
  41.             cout << "You get 0% discount" << endl;
  42.            break;
  43.        case 6:
  44.        case 7:
  45.        case 8:
  46.        case 9:
  47.        case 10:
  48.            cout << "You get 10% discount" << endl;
  49.             break;
  50.            default: cout << "You get 25% discount" << endl;
  51.        }
  52.     }
  53.     return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement