IntermediateBasics & Math25 points

Income tax slabs from a rate table

A payroll firm serves clients in Karachi, London and Johannesburg. Each country taxes annual income in marginal slabs: only the part of the income that falls inside a slab is taxed at that slab's rate. The slab table is supplied with every request, so one program works for every country.

Task: the first line is n, the number of slabs. The next n lines each contain upper rate: the upper limit of the slab (cumulative, so the slab covers income above the previous limit up to this one) and the rate in percent (may have decimals). The last slab has - instead of a limit and covers everything above. The final line is the annual income (a whole number). Print three lines:

  • Tax: X (total tax rounded to 2 decimals, halves up, rounded once at the very end)
  • Effective rate: Y% (tax divided by income times 100, 2 decimals, halves up; print 0.00% when income is 0)
  • Take-home: Z (income minus the rounded tax, 2 decimals)

Sample tests

Input

5
600000 0
1200000 2.5
2200000 12.5
3200000 22.5
- 35
1800000

Expected output

Tax: 90000.00
Effective rate: 5.00%
Take-home: 1710000.00

Input

4
12570 0
50270 20
125140 40
- 45
45000

Expected output

Tax: 6486.00
Effective rate: 14.41%
Take-home: 38514.00

Your answer is also checked against 5 hidden tests.

Need a hint?

Keep track of where the previous slab ended. For each slab, the taxable part is the income capped at the slab limit, minus the previous limit (never below zero).