Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- /*
- Programmer: Bryan Virgil
- Date: 10 04 2017
- Description: Tshirt company is giving the following discounts
- 1..5 --> 0% discounts
- 6..10 --> 10% discounts
- 10+ --> 25% discounts*/
- using namespace std;
- int main()
- {
- int numTShirts;
- cout << "How many T-Shirts did you purchase:";
- cin >> numTShirts;
- if (cin.fail())
- {
- cout << "Wrong data type, please run the program" << endl;
- }
- else
- {
- if (numTShirts < 1)
- {
- cout << "Invalid quantity, please run the program again" << endl;
- cout << "Exiting..." << endl;
- exit(EXIT_FAILURE);
- }
- // get rid of the exit and implement the else part
- // else
- switch(numTShirts)
- {
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- cout << "You get 0% discount" << endl;
- break;
- case 6:
- case 7:
- case 8:
- case 9:
- case 10:
- cout << "You get 10% discount" << endl;
- break;
- default: cout << "You get 25% discount" << endl;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement