//Ryan Shahriyarpour CS1A Carl Argila CH4 HW Q:5
//
/*****************************************************************************
*
* Software Sales
*
*********************
*
* A software company sells a package that retails for $99. discounts
* are given according to the following rules of the company:
* 10-19 units = 20% discount
* 20-49 units = 30% discount
* 50-99 units = 40% discount
* 100+ units = 50% discount
*
* INPUT
* units : Number of units sold
*
* OUTPUT
* totalCost : Total cost of the purchase
*
****************************************************************************/
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
const double PRICE = 99.0;
int units;
double discount = 0.0;
double totalCost;
cout << "Enter the number of units sold: ";
cin >> units;
// Input validation
if (units <= 0)
{
cout << "Error: Number of units must be greater than 0.\n";
return 0;
}
// Determine discount based on quantity
if (units >= 100)
discount = 0.50;
else if (units >= 50)
discount = 0.40;
else if (units >= 20)
discount = 0.30;
else if (units >= 10)
discount = 0.20;
// Calculate total cost
totalCost = (units * PRICE) * (1.0 - discount);
// Display result
cout << fixed << setprecision(2);
cout << "Total cost: $" << totalCost << "\n";
return 0;
}