discount_percent is defined as an int. You try to assign values that are floating point values that are less than 1. 0.10 and 0.18 are integer truncated to 0.
If you declared discount_percent as either a float or double then the assigned values would work.
#include <iostream>
#include <iomanip>
usingnamespace std;
int main()
{
//constant regular price variable
constdouble REGULAR_PRICE {99.0};
//variables
int units_sold {};
double discount_percent {};
//get user input of number of units
cout << "Number of units purchased is: ";
cin >> units_sold;
//Pre-discount amount
constauto pre_discount_amount {units_sold * REGULAR_PRICE};
cout << setprecision(2) << fixed;
if (units_sold >= 10 && units_sold <= 39)
discount_percent = .10;
elseif (units_sold >= 40 /* && units_sold <= 65*/)
discount_percent = .18;
constauto savings {pre_discount_amount * discount_percent};
cout << "Number of units purchased is: " << units_sold
<< "\nDiscount applied is: " << discount_percent * 100 << "%"
<< "\nTotal savings due to discount is: " << savings
<< "\nTotal cost of the purchase is: " << (units_sold * REGULAR_PRICE) - savings << '\n';
}
Number of units purchased is: 50
Number of units purchased is: 50
Discount applied is: 18.00%
Total savings due to discount is: 891.00
Total cost of the purchase is: 4059.00