Sorry, 1 qns to ask

J

JeffJak

Gas Used Rate
First 100 cubic meters $5.00 minimum cost
Next 200 cubic meters 4 cents per cubic meters
Next 200 cubic meters 2 cents per cubic meters
Above 500 cubic meters 1 cent per cubic meters

I need to create a java to calculate this ^
i only know for the first 100 cm
(gas <= 100)
{cost = 5.00;
}


but i dont know how to do the next steps..
can u just show me the next step to calculate the "next 200cm" and i
will try to continue on myself.
Thanks in advance.!!
 
G

Gordon Beaton

but i dont know how to do the next steps.. can u just show me the
next step to calculate the "next 200cm" and i will try to continue
on myself.

Here's a hint: start at the other end! Check first for >500, calculate
the price for the part that exceeds 500, then subtract those and move
*down* to the next level.

/gordon

--
 
J

JeffJak

Here's a hint: start at the other end! Check first for >500, calculate
the price for the part that exceeds 500, then subtract those and move
*down* to the next level.

/gordon

--

so i need to declare a few variations?? eg, ans 1 = ans2 - 100
cost = ans2 *0.05
 
T

Thomas Fritsch

JeffJak said:
Gas Used Rate
First 100 cubic meters $5.00 minimum cost
Next 200 cubic meters 4 cents per cubic meters
Next 200 cubic meters 2 cents per cubic meters
Above 500 cubic meters 1 cent per cubic meters

I need to create a java to calculate this ^
i only know for the first 100 cm
(gas <= 100)
{cost = 5.00;
}
if (gas >= 100 and gas <= 200)
{cost = 5.00 + (gas - 100) * 0.04;
}

and so on...
(the formulas for the next gas ranges will get more and more complicated)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top