Shown below is the 2001 Federal Income tax table for single taxpayers. This prog
ID: 3636809 • Letter: S
Question
Shown below is the 2001 Federal Income tax table for single taxpayers. This program requires using If-blocks, which are discussed in weeks 3 and 4, so you may have to access the week 3 lecture notes before getting a good idea of how to complete the program.Taxable Income From Up to but not including Tax is
0 $27,050 15% of the income
$27,050 $65,550 $4,057.50 (27.5% of the amount over $27,050)
$65,550 $136,750 $14,654.00 (30.5% of the amount over $65,550)
$136,750 $297,350 $36,361.00 (35.5% of the amount over $136,750)
$297,350 and up $93,374.00 (39.1% of the amount over $297,350)
For example, if a single person's income is $70,000, then the tax calculation for tax owed would be:
$14,654.00 (.305 * ($70,000 - $65,550)) = $16,011.25
Write a program using if-blocks that allows the user to input a taxable income value into a text box, and after clicking a button the tax is calculated and displayed in another text box. Write a function to do the tax calculation. Although the answer should be rounded to 2 decimal places, don't worry for the moment about formatting as currency. Your program should calculate the correct tax no matter what the income range. Use an IF-block to make this work.
Explanation / Answer
Here's the interesting part of the program - the if/else statements. I wrote it in Javascript, but if you want Java (you mentioned both) change the variable types to double. Please note that Javascript and Java are not the same thing. Javascript is a scripting language used in browsers, while Java is an application programming language. Javascript was named as such due to the popularity of Java. var income; var tax; if(income < 27050) { tax = 0.15*income; } else if(income < 65500) { tax = 4057.50 + 0.275*(income-27050); } else if(income < 136750) { tax = 14654 + 0.305*(income-65550); } else if(income < 297350) { tax = 36361+0.355*(income-136750); } else { tax = 93.374 + 0.391*(income - 297350); }Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.