Question: The discount.js file must begin with a multi-line comment block that includes your name , and this description : This program will add a couple

 The discount.js file must begin with a multi-line comment block that

includes your name, and this description: This program will add a couple

  1. The discount.js file must begin with a multi-line comment block that includes your name, and this description: This program will add a couple of values, calculate the discount amount, calculate sales tax, and output the subtotal, discounted subtotal amount, the amount of sales tax, and the final total cost to the browser's console.
  2. Following the comment block, the program turns on "strict mode"
  3. Following the "strict mode" statement, the program must declare and initialize all variables to their starting/initial values.
  4. The program uses "const" to assign unchanging values - (the item prices, tax rate, and discount rate).
  5. The program uses "let" to assign values that might change - (the subtotal, tax amount, discount amount, and final total cost).
  6. The program will use a conditional statement ( if/else) to determine if the purchase qualifies for a discount.
  7. The program must use "console.log" to output the discounted subtotal, the amount of sales tax, and the final total cost to the browser's web development tool console.
  8. The output to the console will be formatted using template literals to look something like the below sample. Note in the sample display (below) that your numeric values will be different than this sample output: Subtotal: 232.84 Sales tax: 23.28 Total: 256.12 You must use template literals to format the output. Do not use the (+) concatenation operator to format the output.

Here is my code for total and tax I need you to help me with discount

'use strict' ;

// declaring constant variables whose value doesn't change const backpack = 56.99; const calculator= 104.89; const ruler = 4.32; const textbook = 51.97; const candybar= 1.99; const keychain = 7.22; const tax_rate = 0.10; // declaring total variable using let whose value may change let totalCost = 0, tax_amount = 0, final_total_cost = 0;

// adding the values and storing into total totalCost = backpack + calculator + ruler+ textbook + candybar + keychain; tax_amount = totalCost * tax_rate; //sales tax amoun final_total_cost = totalCost + tax_amount; //final cost after adding sales tax with totalCost

// The program using "console.log" to output the correct result console.log("The total cost is: $" + totalCost); console.log("The sales tax amount is: $" + tax_amount); console.log("Final total cost amount is: $" + final_total_cost);

JavaScript

Calculating a Discount! Discounts are generally offered if certain conditions are met. For example, if you buy a certain product, or you buy a certain quantity or if you spend more than a certain amount. The discount is calculated and then subtracted from the subtotal before the sales tax is calculated. The discount rate (just like the tax rate) needs to be initialized as a decimal number. You will use 0.20 instead of "20%". First, add the price of all items to create a subtotal. Then, check to see if the customer meets the criteria for the discount. If they meet the criteria, then calculate the discount. To calculate the discount, multiply the subtotal by the discount rate (in decimal format). For example, if the subtotal costs $250 and the discount rate is 20%, then the equation to calculate the discount amount is $250 x 0.20 = $50.00 Then, subtract the discount amount from the subtotal to get the discounted subtotal. Solve this problem Write a JavaScript program that solves the following problem: Youie buys 6 items at the campus bookstore: A backpack, a calculator, a ruler, a textbook, a candy bar, and a keychain. The backpack cost $56.99. The calculator cost $104.89. The ruler cost $4.32. The textbook cost $51.97. The candy bar cost $1.99. The keychain cost $7.22. What is the total cost of the 6 items? The bookstore gives a 20% discount if the prices of the items total more than $200. The bookstore charges a 10% sales tax. What is the subtotal cost for the 6 items? This subtotal value is discounted if the original subtotal is more than $200. What is the amount of sales tax on this purchase? What is the total cost after the sales tax has been added to the subtotal

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!