Warning: some codes
Tax Bracket:
1up to5,070----10%5,071up to8,660----14%8,661up to14,070----23%14,071up to21,240----30%21,241up to40,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.
$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.