Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Set Up This Assignment You will create new folders and files for this assignment. Follow these steps to create the folders and files for this

Set Up This Assignment

You will create new folders and files for this assignment.

Follow these steps to create the folders and files for this assignment:

Create a "week4" folder.

Create an "index.html" file in the "week4" folder. This file will be the main page for this assignment.

Create a "week4/js" folder.

Create a "scripts.js" file in the "week4/js" folder. This file will contain all the JavaScript for this assignment.

Use this array of data for the prices of the 30 items purchased:

const prices = [6.67, 1.38 , 5.77, 20.65, 4.97, 6.40, 7.34, 4.61, 9.81, 8.85, 3.66, 3.38 , 6.68, 6.32, 4.55, 6.55, 70.85, 4.01, 0.81, 8.45, 2.77, 4.38, 5.25, 6.47, 40.22, 6.06, 7.98, 4.02, 2.81, 28.33] ;

Instructions

The program must meet these criteria:

Must follow the standards followed in earlier programs: Has meaningful comments. 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. All code is valid and easy to read.

The HTML file for this assignment must be located at "public_html/csci212/week4/index.html" and use the HTML provided above - which is based on the HTML5 Sample Template.

The JavaScript file for this assignment must be located at "public_html/csci212/week4/js/scripts.js".

Follow the advice on the "Functions: Do One Thing (DOT)" page to break your code up into small reusable functions. At a minimum, you should create a different function for each of these jobs. I've made up some names, but you don't have to use these names:

processPurchase(prices) - This is the main program that calls all the other small functions to solve this program.

addPrices(prices) - accepts an array as the parameter and returns a number.

applyDiscount(subTotal) - accepts a number, returns a number.

discountRate() - returns the current discount rate as a decimal number.

calcSalesTax(subTotal) - accepts a number, returns a number. Calls salesTaxRate() to get the current tax rate.

salesTaxRate() - returns the current tax rate as a decimal number.

Finally, call the main function to execute it.

The program must just template literals to construct the output to the console:

The number of items purchased,

The discount amount

The subtotal,

The sales tax amount

The final total cost.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

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

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions