Question: htmlcode Backpack156.99 Calculator1104.89 Textbook151.97 Subtotal Tax Total Cost Write a JavaScript program that solves the following problem: Youie buys 3 items at the campus bookstore.
htmlcode Backpack156.99 Calculator1104.89 Textbook151.97 Subtotal Tax Total Cost
Write a JavaScript program that solves the following problem:
Youie buys 3 items at the campus bookstore. A backpack, a calculator, and a textbook.
The backpack costs $56.99. The calculator costs $104.89. The textbook costs $51.97.
The bookstore charges 13% sales tax.
What is the subtotal amount for the 3 items?
What is the sales tax amount for the 3 items?
What is the total cost for the 3 items after the sales tax is added to the subtotal?
Instructions
you will read several HTML elements from the provided HTML file using getElementById method.
Then you will read the text content from the HTML elements using "textContent", convert the text into numbers using the Number() property.
Like in the previous assignments, you will do some calculations.
Finally, you will output several values to the console.
This program needs to be written as functions. There must be no variables declared or used in the global scope.
The program must meet these criteria:
- Must follow the standards followed in previous programs: include meaningful comments, is formatted in an easy to read manner, uses strict mode to enforce good coding practices. Variables are initialized at the beginning. Uses "const" and "let" correctly. It does not use "var" to initialize variables. Variables are kept out of global scope by compartmentalizing them inside functions.
- Use document.getElementById to read the prices of the 3 elements from the DOM: back-price, calc-price, and text-price.
- Use the textContent property of the elements to read the text contents from the 3 DOM elements.
- Convert the text content from the 3 DOM elements into numbers using the Number() method.
- Calculate the sum of the item prices.
- Calculate the amount of sales tax.
- Calculate the total price.
- Output the following information to the console using template literals: Sum of the item prices Sales tax amount Total price
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
