Concept

How can if-else-if statements calculate tax across increasing income ranges?

ComputerScienceOne / Life & Taxes

"Next, we can code a series of if-else-if statements for the income range. By placing the ranges in increasing order, we only need to check the upper bounds just as in the original example.\n\n1 if(income <= 18150) {\n\n2 baseTax = income * .10;\n\n3 } else if(income <= 73800) {\n\n4 baseTax = 1815 + (income - 18150) * .15;\n\n5 } else if(income <= 148850) {\n\n6 ...\n\n7 } else {\n\n8 baseTax = 127962.50 + (income - 457600) * .396;\n\n9 }"

Related Ideas

How can if-else-if statements calculate tax across increasing income ranges? | ComputerScienceOne | Bifalgorithm | Bifalgorithm