Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

create an HTML file that contains input elements with event-handling capabilitie

ID: 3733621 • Letter: C

Question

create an HTML file that contains input elements with event-handling capabilities according to the requirements.

The company that needed the flowchart and pseudocode for calculating the Tax Owed amount for tax returns is now giving you the responsibility of creating a program for that purpose. The requirements for performing the calculation remain the same as those indicated for the flowchart:

For citizens younger than 21, the tax applied is one of the following:

8% for income up to $20,000.

12% for income greater than $20,000 up to $50,000.

20% for income greater than $50,000.

For citizens 21 years old or older, the tax applied is one of the following:

10% for income up to $20,000.

15% for income greater than $20,000 up to $35,000.

25% for income greater than $35,000 up to $70,000.

30% for income greater than $70,000.

The formula to calculate the Tax Owed amount is: tax rate percentage x income.

Use radio buttons to acquire the age range of the user. Use a text box to get the user’s income data.

Use a Process button to process the Tax Owed amount.

The button mentioned above should also: Produce an error message (via an alert window) if the user forgets to select a radio button. Produce an error message (via an alert window) if the user forgets to enter income data or enters data that cannot be processed such as text data.

Use text box to display the tax owed amount. Use a Clear button to reset the main variables as well as the radio buttons and text boxes in order to be able to process the next user’s information. The variable names should be descriptive. For example, if a program is calculating the tip given at a restaurant, an appropriate variable name may be tipAmount.

Since the content of a text box - which is what the prompt() function generates - is going to be used in mathematical operations, use the function parseInt() to ensure that the numeric input is treated as numeric data. Syntax example: numericVariable = parseInt(numericVariable)

Explanation / Answer

<html>
<body>

<input type="radio" id="age" value=0>Younger than 21<br>
<input type="radio" id="age" value=1>21 or older<br>
<button>Process</button>
<button>Clear</button>


<script>
function del(){
var ele = document.getElementsById("age");
   for(var i=0;i<ele.length;i++)
      ele[i].checked = false;
delete salary;
document.getElementById("demo").innerHTML=" ";
}

function Tax(){
var tax=0;
var salary=parseInt(prompt("Enter Salary"));
var age=parseInt(document.getElementById("age").value);
if(isNaN(salary))
window.alert("Invalid input");
if(age==0)
{
if(salary<=20000)
   tax=0.08*salary;
else if(salary<=50000)
   tax=0.12*salary;
else
    tax=0.2*salary;
}

else if(age==1)
{
if(salary<=20000)
   tax=0.1*salary;
else if(salary<=35000)
   tax=0.15*salary;
else if(salary<=70000)
   tax=0.25*salary;
else
   tax=0.3*salary;
}

else
{
window.alert("Enter age field");
}
document.getElementById("demo").innerHTML="Tax Due is $"+tax;
}
</script>

</body>
</html>