Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Objectives You will demonstrate skills / techniques learned from earlier assignments. You will demonstrate the use of a conditional statement to check if a condition
Objectives
You will demonstrate skillstechniques learned from earlier assignments.
You will demonstrate the use of a conditional statement to check if a condition is true or false.
You willdemonstrate the use of the subtraction operator to subtract the discount from the subtotal.
You will demonstrate the use of template literals to format the output.
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 instead of
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 $ and the discount rate is then the equation to calculate the discount amount is $$
Then, subtract the discount amount from the subtotal to get the discounted subtotal.
Then, you must calculate the amount of sales tax on the new subtotal.
Finally, you add that sales tax amount to the new subtotal to calculate the total cost. For example, if the subtotal is $ and the amount of sales tax is $ then the equation to calculate the total cost is $$$
Set Up This Assignment
You will use the "week folders that you ereated in a previous assignment, but you will create new files for this assignment.
Steps for creating the files for this assignment:
Create a discount.html file in the "csciweek folder. This file will be the main page for this assignment.
Create a discount.js file in the "csciweekjs folder. This file will have all the JavaScript for this assignment.
Solve this Problem
Write a JavaScript program that solves the following problem:
Youie buys items at the campus bookstore:
A backpack, a calculator, a ruler, a textbook, a candy bar, and a keychain.
The backpack cost $ The calculator cost $ The ruler cost $ The textbook cost $ The candy bar cost $ The keychain cost $
What is the total cost of the items?
The bookstore gives a discount if the prices of the items total more than $
The bookstore charges a sales tax.
What is the subtotal cost for the items? This subtotal value is discounted if the original subtotal is more than $
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started