Again i tried too many ways but i failed it's really hard i hate that

Suppose charges by a gas company are based on the user’s consumption, according to the following table:

Gas Used Rate

First 70 cubic meters $5.00 minimum cost
Next 100 cubic meters 5.0 cents per cubic meter
Next 230 cubic meters 2.5 cents per cubic meter
Above 400 cubic meters 1.5 cents per cubic meter

Ensure that you charge only once at the correct rate for each cubic meter of gas.

Write a program that computes the charges for a given amount of gas usage. Have the program read in the meter reading for the previous month and the reading for the current month, each an integer with up to 4 digits, and each reading representing cubic meters. The program should then calculate and display the amount of payment due from the customer. NOTE: The reading for the current month could be less than the reading for the previous month, because after the reading reaches 9999, it starts over with the value 0000. For example, if the previous month’s reading was 9875 and the current month’s reading was 0078, the customer actually used 203 cubic meters during the current month. This can probably be calculated in a variety of ways. A straightforward way, of course, is to subtract 9875 from 10000 and add 78 to the result. This approach will be satisfactory for our purposes, when the current reading is less than the previous reading, i.e., in that case uses the following formula:

Gas used = 10000 - previous reading + current reading

If the current reading is greater than the previous reading, then of course we just have to subtract the previous reading from the current reading.

Display your result in the way illustrated by the following example:

Last Month’s Reading: 9875 cubic meters
This Month’s reading: 0078 cubic meters
Gas Used: 203 cubic meters
Total Charges: $10.83
Again, looks fun, what (specifically again) do you need help with?
i want to know how to write it perfectly
You're going to need 4 variables:

one for last months meter reading
one for this months meter reading
the amount of gas used
and the dollar amount to be charged

You will need to ask the user to input both the readings for last month and this month and then calculate the amount of gas used based on that input. The equations needed to figure out how to determine the amount of gas used is provided.

After that you can use either nested if statements, or even a for loop to calculate the total based on the gas usage

It's really simple, and if you show us some code to show what you have so far we'd be happy to help guide you in the right direction, but don't expect us to do your homework for you.
Topic archived. No new replies allowed.