In: Computer Science
A local T-shirt company is running a promotion as follows: For customers that buy less than 5 TShirts, there is no disconut. If a customer buys: between 6 and 10 Tshirts they get 10% discount. between 11 and 20 TShirts they get 20% discount. between 21 and 100 TShirts they get 50% discount. Write a C++ program that prompts the user for a number of TShirts. Assuming that a TShirt costs $10, calculate the appropriate discounts and display the number of TShirts bought, total amount, discount amount, and total amount due. For example, if the user bought 11 TShirts, the program should display the following: Number of TShirts bought: 11 Total amount : $ 110 Discount amount : $ 22 Total amount due : $ 88 If the user enters negative values or a 0 for number ofTshirts display an error message and ask them to run the program again.
Check
the above images.
Its an image of handwritten program for the question.
#include<iostream>
using namespace std;
int main( )
{
int n, total, dis;
cout<<"Enter no. of shirts:\n";
cin>>n;
if(n<=0)
cout<<"error";
else if((n>1)&&(n<=5))
{
dis=0;
total=50;
goto display;
}
else if((n>=6)&&n<=10)
{
dis=(n*10*10)/100;
total=n*10;
goto display;
}
else if((n>=11)&&(n<=20))
{
total=n*10;
dis=(n*10*20)/100;
goto display;
}
else if((n>=21)&&(n<=100))
{
total=n*10;
dis=(n*10*50)/100;
}
display:
int due= total-dis;
cout<<"Total amount=$"<<total;
cout<<"\nDiscount amount =$"<<dis;
cout<<"\n Total amount due=$"<<due;
return 0;
}