I'm trying to figure out how to round a monetary using this Rules:
Tax calculated | Taxe imputed |
|---------------|--------------|
| 0.99 | 1.00 |
| 1.00 | 1.00 |
| 1.01 | 1.05 |
| 1.02 | 1.05 |
I tried various methods for rounding but always I get an error:
I have 2 books at 12.49€ with tax 10%; and one cd at 14.99€ with tax 20%
I tryied this method but always get false result
double number = 12.49 * 0.1 * 2;
double number2 = 14.99 * 0.2;
double round1 = Math.round(number * 100.0 /5.0) * 5.0 / 100.0;
double round2 = Math.round(number2 * 100.0 /5.0) * 5.0 / 100.0;
the console print 5.5 (round1+round2) but I should get 5.53
Help Please