A software company sells a package that retails for $99. Quantity discounts are given according to the following table:
Quantity Discount
10-19 20%
20-49 30%
50-99 40%
100 or more 50%
Write a program that asks the user to enter the number of packages purchased. The program should then display the amount of the discount (if any) and the total amount of the purchase after the discount.
Answers
Program in C++:
#include<iostream>
using namespace std;
int main()
{
int package;
cout<<"Enter total number of packages : ";
cin>>package;
double price = 99 * package;
double discount;
if(package < 10)
{
discount = 0;
}
else if(package >= 10 && package <= 19)
{
discount = price * 20.0 / 100.0;
}
else if(package >= 20 && package <= 49)
{
discount = price * 30.0 / 100.0;
}
else if(package >= 50 && package <= 99)
{
discount = price * 40.0 / 100.0;
}
else
{
discount = price * 50.0 / 100.0;
}
double net_amount = price - discount;
cout<<"Total price = $"<<price<<endl;
cout<<"Discount = $"<<discount<<endl;
cout<<"Price after discount = $"<<net_amount;
return 0;
}
Output:
Enter total number of packages : 25
Total price = $2475
Discount = $742.5
Price after discount = $1732.5