# JavaScript Programming Assignment Help, JavaScript Homework Help

Part 1: Develop the Sales Tax Calculator

In this assignment, you’ll develop an application that calculates the sales tax and invoices total after the user enters the subtotal and tax rate.

1.Open the HTML and JavaScript files in this folder:
JavaScriptProgramming-Assignment3\sales_tax\
Then, run the application to see the user interface shown above, although that interface won’t do anything until you develop the JavaScript for it.

2. In the JavaScript file, note that the \$ function has been coded for you. It gets the object for the HTML element that’s specified by the id attribute.

3. Code an event handler (function) named processEntries() that gets the user entries, calculates the sales tax and total, and displays those results in the textboxes.

4. Code an unload event handler that attaches the processEntries() function to the click event of the Calculate button. Then, test what you have so far.

5.Add data validation to the processEntries() function. The subtotal entry should be a valid, positive number that’s less than 10,000. The tax rate should be a valid, positive number that’s less than 12. The error messages should be displayed in alert dialog boxes, and the error messages should be:
Subtotal must be > 0 and < 10000 TaxRate must be > 0 and < 12

6. Add JavaScript that moves the cursor to the Subtotal field when the application starts and when the user clicks on the Calculate button.

7. Add the JavaScript event handler for the click event of the Clear button. This should clear all text boxes and move the cursor to the Subtotal field.

8.add JavaScript event handlers for the click events of the Subtotal and Tax Rate text boxes. Each handler should clear the data from the text box.

Part 2: Develop the Change Calculator

In this assignment, you’ll develop an application that tells how many quarters, dimes, nickels, and pennies are needed to make change for any amount of change from 0 through 99 cents. One way to get the results is to use the divide and modulus operators along with the parseInt() method for truncating the results so they are whole numbers.

1.Open the HTML and JavaScript files in this folder:
JavaScriptProgramming-Assignment3\change_maker\
Then, run the application to see the user interface shown above, although that interface won’t do anything until you develop the JavaScript for it.

2.In the JavaScript file, note that the \$ function has already been coded.

3.Code an event handler named processEntry() that gets the user’s entry and checks to make sure that it is a number between 0 and 99. If it isn’t, display an alert dialog box for the error. If it is valid, call a function named makeChange() and pass it to the user entry.

4. Code the makeChange() function, which should have one parameter that accepts the user’s entry. This function shouldn’t return anything, but it should display the results in the text boxes for Quarters, Dimes, Nickels, and Pennies.

5.Code an unload event handler that attaches the processEntry() event handler to the click event of the Make Change button. Then, test this application.

In this assignment, you’ll use nested if statements and arithmetic expressions to calculate the federal income tax that is owed for a taxable income amount.

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

1.Open the HTML and JavaScript files in this folder:
JavaScriptProgramming-Assignment3\income_tax\

Note that the JavaScript file has some starting JavaScript code for this application, including the \$ function and an unload 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.

2. Code the processEntry() function. It should get the user’s entry and make sure it’s a valid number greater than zero. If it isn’t, 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.

3. Code the calculateTax() function, but to start, just write the code for calculating the tax for any amount within the first two brackets in the table above. The user’s entry should be converted to an integer, and the tax should be rounded to two decimal places. To test this, use income values of 9275 and 37650, which should display taxable amounts of 927 and 5183.50.

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

Develop the Temperature Converter
In this assignment, you’ll use radio buttons to determine whether the conversion is from Fahrenheit to Celsius or vice versa. You’ll also modify the DOM so the labels change when a radio button is clicked. When the application starts, it will look like this:

When the user clicks on the second radio button, the labels will change so the interface will look like this:

1. Open the HTML and JavaScript files in this folder:
JavaScriptProgramming-Assignment4\convert_temps\
2. Note that the JavaScript file has some starting JavaScript code, including the \$ function, a clearTextBoxes() function, and an onload event handler that attaches three event handlers named convertTemp(), toCelsius(), and toFahrenheit().
3. Code the toFahrenheit() function that is executed when the user clicks on
the second radio button. It should change the text in the labels for the text
boxes so they read as in the second interface above. It should also call
the clearTextBoxes() function to clear the text boxes.
4. Code the toCelsuis() function that is executed when the user clicks on the
first radio button. It should change the text in the labels for the text boxes
so they read as in the first interface above. It should also call the
clearTextBoxes() function to clear the text boxes.
5. Code the convertTemp() function without any data validation. It should
calculate the temperature based on which button is checked. To convert
Fahrenheit to Celsius, first subtract 32 from the Fahrenheit temperature,
and then multiply that result by 5/9. To convert Celsius to Fahrenheit, first
multiply Celsius by 9/5, and then add 32. The result in either case should
be rounded to zero decimal places.
6. Add data validation to the convertTemp() function. The only test is
whether the entry is a valid number. If it isn’t, this message should be
displayed in a dialog box: “You must enter a valid number for degrees.”
7. Add any finishing touches to the application like moving the focus to the
first text box whenever that’s appropriate.

Use a Test Score array
In this assignment, you’ll work with an array and you’ll add nodes to the DOM to display
the Results and the Scores.

1. Open the HTML and JavaScript files in this folder:
JavaScriptProgramming-Assignment4\test_scores\
Then, run the application to see the user interface shown above, although that
interface won’t do anything until you develop the JavaScript for it.
2. At the start of the JavaScript file, you’ll see the declarations for two arrays: one for
names and one for scores, and each array contains four elements. You’ll also see
the code for the \$ function as well as an onload event handler that attaches three
functions named addScore(), displayResults(), and displayScores() to the click
events of the buttons.
3. Write the displayResults function(). It should derive the average score and the
highest score from the arrays and then display the results in the div element with
“results” as its id, as shown above. To display the results, you need to add nodes to
the DOM with the heading as an h2 element and the average and highest scores as
elements. The easiest way to do that is to use the innerHTML property as
shown in figure 6-13.
4. Write the displayScores() function. It should get the names and scores from the
arrays and display them as rows in the HTML table element with “scores_table” as
its id, as shown above.
5. Write the addScore() function. It should add a name and score to the two arrays.
To test whether this works, you can click the Display Scores button and see if the
new name and score have been added to the table.
6. If you haven’t already done it, add data validation to addScore() function. The
Name entry must not be empty and the Score entry must be a positive number from
0 through 100. If either entry is invalid, use the alert() method to display this error
message: “You must enter a name and a valid score”.
7. Make sure that your application moves the cursor to the Name field when the
application starts and after a name and score have been added to the array.

Modify the FAQs application
This assignment has you make a minor modification to the FAQs application. When you’re done, this
application should work the same as before, except that only one answer can be displayed at a time. In
other words, when the user clicks on a heading to display the answer, the other answers must be hidden.

1. Open the HTML and JavaScript files in this folder:
JavaScriptProgramming-Assignment4\faqs\
Then, run the application to refresh your memory about how it works.
2. Add code to the toggle() function so only one answer can be displayed at a time. To do that, create
an array of the h2 elements. Then, use a for loop to go through the h2 elements in the array and
remove the class attribute for all h2 elements that aren’t the one that has been clicked. You also
need to remove the class attributes for all of the div siblings of the h2 elements that weren’t clicked.