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.!!
Gordon Beaton - 14 May 2007 14:43 GMT
> 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
--
JeffJak - 14 May 2007 14:51 GMT
> > 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
[quoted text clipped - 7 lines]
>
> --
so i need to declare a few variations?? eg, ans 1 = ans2 - 100
cost = ans2 *0.05
Thomas Fritsch - 14 May 2007 15:31 GMT
> Gas Used Rate
> First 100 cubic meters $5.00 minimum cost
[quoted text clipped - 7 lines]
> {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)
> 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.!!

Signature
Thomas