Question: Extra 4-3 Develop the Income Tax Calculator In this exercise, youll use nested if statements and arithmetic expressions to calculate the income tax that is

Extra 4-3 Develop the Income Tax Calculator

In this exercise, youll use nested if statements and arithmetic expressions to calculate the income tax that is owed for a taxable income amount. When a user enters his taxable income and clicks the Calculate button, this application will display the federal income tax owed.

This is the 2015 table for the federal income tax on individuals that you should use for calculating the tax:

Taxable income

Income tax

Over

But not over

Of excess over

$0

$9,225

$0 plus 10%

$0

$9,225

$37,450

$922.50 plus 15%

$9,225

$37,450

$90,750

$5,156.25 plus 25%

$37,450

$90,750

$189,300

$18,481.25 plus 28%

$90,750

$189,300

$411,500

$46,075.25 plus 33%

$189,300

$411,500

$413,200

$119,401.25 plus 35%

$411,500

$413,200

$119,996,25 plus 39.6%

$413,200

Note that the JavaScript file has some starting JavaScript code for this application, including the $ function and an onload event handler that attaches a function named processEntry to the click event of the Calculate button.

Code the processEntry function. It should get the users entry and make sure its a valid number. If it isnt, it should display an error message. If it is valid, it should pass the value to a function named calculateTax, which should return the tax amount. That amount should then be displayed in the second text box.

Code the calculateTax function, but to start just write the code for calculating the the tax for any amount within the first two brackets in the table above. The tax should be rounded to two decimal places, and it should be returned to the calling function. To test this, use income values of 9225 and 37450, which should display taxable amounts of 922.50 and 5156.25.

Add the JavaScript code for the next tax bracket. Then, if you have the time, add the JavaScript code for the remaining tax brackets.

HTML code:

Income Tax Calculator

Income Tax Calculator

Here is the start of the Javascript code:

"use strict";

var $ = function (id) {

return document.getElementById(id);

};

window.onload = function () {

$("calculate").onclick = processEntry;

};

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!