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 tocalculate 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. Use document.write to display your output. Personalize the page with your photo on the top. FTP/Publish the file to the webpage.pace.edu server and submit the link on Blackboard. If you don’t FTP/Publish you will get a zero. If you did FTP/Published and you don’t submit the http:// link to your assignment, you will get a zero also. (Because I won’t know if you published it or not and I need a direct link to your assignment.)

JavaScript Program for Calculating Sales Tax and Total Price of an Item

The objective of this JavaScript program is to calculate the sales tax and total price of an item. We will assume a sales tax rate of 8% and prompt the user to input the cost of the item. We will then convert this input to a numeric format using parseFloat.

To begin, we will declare a variable named “cost” to store the inputted cost of the item. We will use the prompt function to ask the user for the input and parseFloat to convert the input to a numeric value.

“`
let cost = parseFloat(prompt(“Enter the cost of the item:”));
“`

Next, we will calculate the sales tax amount using the formula: salesTax = cost * 0.08. We will declare a variable named “salesTax” and assign it the value obtained from the calculation.

“`
let salesTax = cost * 0.08;
“`

After that, we will calculate the total cost of the item by adding the original cost and the sales tax amount. We will declare a variable named “totalCost” and assign it the sum of “cost” and “salesTax”.

“`
let totalCost = cost + salesTax;
“`

Now, we will output the item cost, tax amount, and total cost in the form of a receipt. We will use document.write to display the output.

“`
document.write(“

Receipt

“);
document.write(“Item Cost: $” + cost.toFixed(2) + “
“);
document.write(“Tax Amount: $” + salesTax.toFixed(2) + “
“);
document.write(“Total Cost: $” + totalCost.toFixed(2) + “
“);
“`

Finally, to personalize the page, we can add our photo to the top of the page. To achieve this, we will include a line of code that displays an image tag with the path to our photo.

“`
document.write(“Your Photo“);
“`

To make the program accessible on the webpage, we need to FTP or publish the file to the webpage.pace.edu server. Once published, we can submit the HTTP link to the assignment on Blackboard for evaluation.

By following this program, we can calculate the sales tax and total price of an item in JavaScript and personalize the page with our photo on top.

Need your ASSIGNMENT done? Use our paper writing service to score better and meet your deadline.


Click Here to Make an Order Click Here to Hire a Writer