Help on understanding tax bracket computation

48 Views Asked by At

Warning: some codes

Tax Bracket:

  • 1 up to 5,070 ---- 10%
  • 5,071 up to 8,660 ---- 14%
  • 8,661 up to 14,070 ---- 23%
  • 14,071 up to 21,240 ---- 30%
  • 21,241 up to 40,230 ---- 33%
  • Higher than 40,230 ---- 45%

I understand the concept of progressive tax, wherein if I have an income of 50,000. Then each chunk of that amount that falls into the bracket will be taxed accordingly.

I searched the internet and found a sample code/program for this.

if (income > 40230) 
    return 0.45 * (income - 40230) + 10671.6;
else if (income > 21240)
    return 0.33 * (income - 21240) + 4404.9;
else if (income > 14070)
    return 0.30 * (income - 14070) + 2253.9;
else if (income > 8660)
    return 0.23 * (income - 8660) + 1009.6;
else if (income > 5070)
    return 0.14 * (income - 5070) + 507;
else
    return 0.10 * income;

My question to help me understand the program:

On the first return statement, can anyone explain where the constant 10671.6 came from? Sorry for asking this, but I can't seem to understand where it came from. Same goes for the numbers (4404.9, 2253.9, 1009.6, 507) on the succeeding return statements.

1

There are 1 best solutions below

1
On BEST ANSWER

$10671.6$ is the tax on the first $40230$, calculated as $0.1\cdot 5070+0.14(8660-5070)+0.23(14070-8660)+0.3(21240-14071)+0.33(40230-21240)$

The others are the lower pieces of this.