Waiting for answer This question has not been answered yet. You can hire a professional tutor to get the answer.

# Lesson 4 Exercises4_1. Sales Tax Calculator:Write a JavaScript program that calculates the sales tax and total price of an item. Assume a sales tax rate of 8%, which means you will multiply the cost o

Lesson 4 Exercises

4_1. Sales Tax Calculator:

Write a JavaScript program that calculates the sales tax and total price of an item. Assume a sales tax rate of 8%, which means you will multiply the cost of the item by .08 in order to calculate the tax amount.

Use prompt and parseFloat to ask the user to input the item’s cost and convert it to a numeric format. Declare a variable salesTax and use the formula above to calculate the sales tax amount. Declare a variable totalCost, add the item’s cost plus the sales tax amount, and store it in totalCost. Output the Item cost, tax amount, and total cost on separate lines in the form of a receipt.

Enhancements:

Don’t assume a tax rate of 8%. Instead, ask the user to input the tax rate in the form

of a decimal, i.e. .05, .03, etc., and use this tax rate for the calculations.

Display the tax amount in a different color.

Depending on the price of an item, you may end up with a tax amount that takes up

more than 2 decimal places. Use the following code to round the tax amount to two decimal places:

var taxAmtRnd = Math.round(taxAmount*100); taxAmtRnd = taxAmtRnd/100;

This code multiplies the tax amount by 100, rounds it off, then divides by 100. This drops any extra decimal places from the tax amount. The rounded tax amount is in the variable taxAmtRnd.