Answered step by step
Verified Expert Solution
Link Copied!

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 skills/techniques learned from earlier assignments.
You will demonstrate the use of a conditional statement to check if a condition is true or false.
You will/demonstrate 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 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 $2500.20=$50.00.
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 $200, and the amount of sales tax is $20, then the equation to calculate the total cost is $200+$20=$220.00.
Set Up This Assignment
You will use the "week2" folders that you ereated in a previous assignment, but you will create 2 new files for this assignment.
Steps for creating the files for this assignment:
Create a discount.html file in the "csci212/week2" folder. This file will be the main page for this assignment.
Create a discount.js file in the "csci212/week2/js" 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 6 items at the campus bookstore:
A backpack, a calculator, a ruler, a textbook, a candy bar, and a keychain.
The backpack cost $56.24. The calculator cost $104.25. The ruler cost $4.26. 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?
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Filing And Computer Database Projects

Authors: Jeffrey Stewart

2nd Edition

007822781X, 9780078227813

More Books

Students also viewed these Databases questions

Question

1. Explain how business strategy affects HR strategy.

Answered: 1 week ago