Question: Objectives In this assignment you will: You will demonstrate skills/techniques learned from earlier assignments. You will demonstrate the use of a simple array . You

Objectives

In this assignment you will:

  • You will demonstrate skills/techniques learned from earlier assignments.
  • You will demonstrate the use of a simple array.
  • You will demonstrate the use of a "for loop".
  • You will demonstrate the use of the "length property" to get the count of items in the array.

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:

  1. Create a "week3" folder.
  2. Create an "index.html" file in the "week3" folder. This file will be the main page for this assignment.
  3. Create a "week3/js" folder.
  4. Create a "scripts.js" file in the "week3/js" folder. This file will have all the JavaScript for this assignment.

Instructions

Write a JavaScript program that solves the following problem:

Youie buys 12 different items at the campus bookstore.

The bookstore gives a 20% discount if the prices of the items total more than $200.

The bookstore charges a 10% sales tax.

How many items does Youie purchase?

What is the subtotal cost for the 12 items?

What is the amount of the discount that Youie receives?

What is the total cost after the subtotal is added?

The program must meet these criteria:

  1. The HTML file for this assignment will be located at "public_html/csci212/week3/index.html" and be based on the HTML5 Sample Template. This HTML does not need to contain any content. It just needs the HTML from the template.
  2. The JavaScript file for this assignment will be located at "public_html/csci212/week3/js/script.js".
  3. The scripts.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, discount amount, and the final total cost to the browser's console.
  4. Following the comment block, the program turns on "strict mode"
  5. Following the "strict mode" statement, the program must initialize all variables to their starting/initial values.
  6. The program uses "const" to assign unchanging values - (the array of prices, tax rate, and discount rate).
  7. The program uses "let" to assign values that might change - (the subtotal, tax amount, discount amount, and final total cost).
  8. The program uses an array to store all the prices of each item purchased.

    Use this array as the input of this assignment:

    let prices = [ 6.67, 1.38 ,5.77, 6.47, 4.97, 6.40, 7.85, 4.61, 0.81, 8.85, 9.35, 12.87 ] ;

  9. The program uses a "for loop" to loop through each element of the array and adds each item price to the subtotal amount.
  10. The program must use "console.log" to output: 1. the number of items purchased, 2. the item subtotal, 3. the discount amount, and 4. the final total cost.
  11. The number of items purchased displayed in the console must be calculated using the "length" property of the array.

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!