Consider that a tax of 10% is applicable on all items except food. Also, an additional tax of of 5 % is applicable on imported items.
If the cost of a music CD is
You can use long
instead of double
to use double you can do
double d = Math.round(d * 20) / 20.0; // round up to multiple of 0.05
to use long (as cents)
long l = (l + 3) / 5 * 5;
Although its often considered best practice to use int
, long
or BigDecimal
most investment banks and funds use double
because once you understand how to use them safely, they are simpler (than long) and faster (than BigDecimal) to use.