I am learning how to code pretty much entirely on my own, I have a very simple program right now that calculates cost of a package based on weight, however I am wanting to make it so that it does not have a limit on weight and will just keep increasing the cost based on the weight entered.
1 2 3 4 5 6 7 8 9 10 11
cout << "Enter number of ounces. ";
cin >> ounces;
if (ounce <= 20)
cost = 3.00;
elseif (ounce <= 24)
cost = 3.50;
elseif (ounce <= 28)
cost = 4.00
else
cout << "Package is too heavy.";
cout << "Your cost is $ << cost << endl;
is the part of the code determining and outputting the cost. how would I make it so that instead of having to right true/false statements for every 4 ounces, that insead the program automatically adds 50 cents each time the weight goes up more than 4 ounces after the first 16. For example 16 would be $3.00, anything up to 20 will be $3.50, anything after 20 and up to and including 24 would be $4.00, etc?
That comes close however it keeps the 3.00 charge up til 20 then keeps 3.50 until 23 and then moves to 4.00 at 24, when 17-20 should be 3.50 21-24 should be 4.00 etc. It definately is a math problem just not sure where the issue is.