Example 3 - Tax
In the land of Slobovia the tax that citizens are liable to pay is calculated according to the following formula:
- If you earn up to and including 15000 Slobs, then you pay no tax at all!
- If you earn anything between 15000 Slobs and 19500 Slobs then you pay tax at the rate of 10% of however much you earn above 15000, e.g. if a Slobovian earned 17000 Slobs, he would pay 10% of 2000 in tax.
- If you earn 19500 Slobs or above, then you pay nothing on the first 15000 Slobs, 10% of the difference between 15000 and 19500 Slobs (which is 10% of 19500 - 15000 = 10% of 4500 = 450 Slobs) and 25% of the amount that you owe above 19500 Slobs.
If all this seems complicated, try the following program. It will ask you for an income in Slobs, which you should enter using only digits (i.e. no commas or spaces or the like) and it will then tell you how much tax is payable on that income.