Write a C++ program: You were hired by a T-shirt store to write a program to hel
ID: 3589491 • Letter: W
Question
Write a C++ program:
You were hired by a T-shirt store to write a program to help them sell T-shirts online. They are running a special with the following discounts:
T-Shirt Quantity Discount
5-10 5%
11-20 10%
21-30 15%
31+ 20%
Assuming a $10 price for a T-shirt, write a program that will ask the user for the number of T-shirts he or she wishes to purchase and then calculate the discount and the total and present it to the user:
EXAMPLE:
12 T-shirts @ $10 each = $120
Discount 10% = $ 12
Total = $108
Thank you for your business!
Explanation / Answer
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int n;
const int PRICE = 10;
cout<<"Enter the number of T-shirts: "<<endl;
cin >> n;
int total = n * PRICE;
int discount = (total * 10 ) / 100;
cout<<n<<" T-shirts @ $"<<PRICE<<" each = $"<<total<<endl;
cout<<"Discount 10% = $ "<<discount<<endl;
cout<<"Total = $"<<(total-discount)<<endl;
cout<<"Thank you for your business!"<<endl;
return 0;
}
Output:
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.