The below is my code. The problem is that I am not getting the cost correctly based on my conditions. It always displays the total cost something that I don't want. I want to specify some conditions based on which the cost and then the discount is to be calculated. But the code always displays some weird values. What modifications do I need to do in my code to get the conditional based total cost and discounts?
Code:
cost=(cost * 100)
if (cost < 5)
cost=(cost * 100);
else if (cost > 5 && cost < 10);
cost=(100 - (100 * 0.2));
else if (cost > 10 && cost < 20)
cost=(100 - (100 * 0.3));
else if (cost > 20 && cost < 30)
cost=(100 - (100 * 0.4));
else if (cost > 30);
cost=(100 -(100 * 0.5));
discount = (100 - cost);
cout<<"Total cost: " << cost << " and discount: " << discount;
Bookmarks