A cash register must turn a computed tax such as 11.853 into cents. TaxCents reads a price and a tax rate in percent, and prints:
- the tax exactly as the
doublecomputes it; - the tax cut to cents:
(int) (tax * 100) / 100.0; - the tax rounded to cents:
(int) (tax * 100 + 0.5) / 100.0; - the total to pay (price + rounded tax);
- the price split into whole units and cents, using
(int).
For the input
197.55 6
the program prints
Tax, as computed: 11.853000000000002
Tax cut to cents: 11.85
Tax rounded to cents: 11.85
Total to pay: 209.4
The price is 197 units and 55 cents