-
Problem
It doesn't display the cost correctly. It just calculates the total x without taking into account the discount. What would I have to change/add to get the total cost after it calculates the discount?
double cost;
double total_cost;
double value;
int x;
float discount;
cout<<"Enter the number of units sold: ";
cin>> x;
cost=(quantity * 99);
cost=(x * 50);
if (x < 10)
discount=(0.0);
else if (x < 20)
discount=(0.2);
else if ( x < 40 )
discount=(0.3);
else if (x < 50)
discount=(0.4);
else
discount=(0.5);
value=(cost*discount);
total_cost= (cost - value);
cout<<"Total cost " << total_cost;
-
This is in the process of being answered elsewhere.
By the way, you should use topic titles that are more descriptive than "Problem".
-
Seems I can't change the title now.
-
Code:
double cost;
double total_cost;
double value;
int x;
float discount;
cout<<"Enter the number of units sold: ";
cin>> x;
cost=(quantity * 99);
cost=(x * 50);
if (x < 10)
discount=(0.0);
else if (x < 20)
discount=(0.2);
else if ( x < 40 )
discount=(0.3);
else if (x < 50)
discount=(0.4);
else
discount=(0.5);
value=(cost*discount);
total_cost= (cost - value);
cout<<"Total cost " << total_cost;
Saved for posterity.
-