Question: Develop the Income Tax Calculator Using nested if statements and arithmetic expressions to calculate the federal income tax that is owed for a taxable income

Develop the Income Tax Calculator

Using nested if statements and arithmetic expressions to calculate the federal income tax that is owed for a taxable income amount. This is the 2020 table for the federal income tax on individuals that you should use for calculating the tax:

 Develop the Income Tax Calculator Using nested if statements and arithmetic Open the HTML and JavaScript files the starter code file linked with the assignment Note that the JavaScript file has some starting JavaScript code for this application, including the $() function and a DOMContentLoaded event handler that attaches a function named processEntry() to the click event of the Calculate button and moves the focus to the first text box. Code the processEntry() function. It should get the users entry and make sure its a valid number greater than zero. If it isnt valid, 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. The focus should be moved to the first text box whether or not the entry is valid. Code the calculateTax() function. To start, just write the code for calculating the tax for any amount within the first two brackets in the table above. The users entry should be converted to an integer, and the tax should be rounded to two decimal places. To test this, use income values of 9875 and 40125, which should display taxable amounts of 987.50 and 4,617.50. Add the JavaScript code for the remaining tax brackets.

HTML File: index.html

Income Tax Calculator

Income Tax Calculator

JavaScript File: calculate_tax.js

"use strict";

const $ = selector => document.querySelector(selector);

document.addEventListener("DOMContentLoaded", () => {

// add event handlers

$("#calculate").addEventListener("click", processEntry);

});

\begin{tabular}{|r|r|l|r|} \hline \multicolumn{2}{|l|}{ Taxable income } & \multicolumn{2}{l|}{ Income tax } \\ \hline Over... & But not over... & & Of excess over... \\ \hline$0 & $9,875 & $0 plus 10% & $0 \\ \hline$9,875 & $40,125 & $987.50 plus 12% & $9,875 \\ \hline$40,125 & $85,525 & $4,617.50 plus 22% & $40,125 \\ \hline$85,525 & $163,300 & $14,605.50 plus 24% & $85,525 \\ \hline$163,300 & $207,350 & $33,271.50 plus 32% & $163,300 \\ \hline$207,350 & $518,400 & $47,367.50 plus 35% & $207,350 \\ \hline$518,400 & & $156,235.00 plus 37% & $518,400 \\ \hline \end{tabular}

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!