Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1-The local T- shirt shop sells shirts that retail for $12. Quantity discounts a

ID: 3620996 • Letter: 1

Question

1-The local T- shirt shop sells shirts that retail for $12. Quantity discounts are given as follows:

Number of Shirts                         Discount
5-10                                              10%
11-20                                           15%
21-30                                            20%
31 or more                                    25%


Write a program that prompts the user for the number of shirts required and computes the total price.
sample Run is like the following:
how many shirts would you like? 4
The cost per shirt is $12 and the total cost is $48.

2- If the number of T-shirts is less than than 5, there is no discount applied.In this program, you need to use the if else if structure. Use constant variables for the unit price and different discount rates.

Now modify your program to do the following with switch. First display the qualified discount rate table together with a category number, and ask the user to choose one category by input an integer from 1-5. Based on the user input of the category number, you should use a switch statement to determine the correct discount percentage. Finally you should calculate and display the discounted price for one T- shirt. Also pay attention to the input validation.

Sample Run is like the following:

Discount        Category

0%                  1

10%                2

15%               3

20%               4

25%                 5
Please select your qualified discount category (1-5): 2

The cost per shirt is $10.88


Explanation / Answer

please rate - thanks

#include <iostream>
#include <iomanip>
using namespace std;
int main()
{int shirts;
double price=12,total,discount,discountedprice;
cout<<"how many shirts would you like? ";
cin>>shirts;
if(shirts>=31)
     discount=25;
else if(shirts>=21)
     discount=20;
else if(shirts>=11)
     discount=15;
else if(shirts>=5)
     discount=10;
else
     discount=0;
discount/=100;
discountedprice=(1.-discount)*price;
cout<<"The cost per shirt is $"<<setprecision(2)<<fixed<<
     discountedprice<<" and the total cost is $"<<discountedprice*shirts<<". ";
system("pause");
return 0;
}   

--------------------------------

#include <iostream>
#include <iomanip>
using namespace std;
int main()
{int shirts,cat;
double price=12,total,discount,discountedprice;
cout<<"how many shirts would you like? ";
cin>>shirts;
cout<<"Discount   Category ";
cout<<"0%              1 ";
cout<<"10%             2 ";
cout<<"15%             3 ";
cout<<"20%             4 ";
cout<<"25%             5 ";
cout<<"Please select your qualified discount category (1-5): ";
cin>>cat;
switch(cat)
{case 5:
     discount=25;
     break;
case 4:
     discount=20;
     break;
case 3:
     discount=15;
     break;
case 2:
     discount=10;
     break;
case 1:
     discount=0;
     }
discount/=100;
discountedprice=(1.-discount)*price;
cout<<"The cost per shirt is $"<<setprecision(2)<<fixed<<
     discountedprice<<" and the total cost is $"<<discountedprice*shirts<<". ";
system("pause");
return 0;
}