Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem to solve: A high-end department store has chosen five customers at random and will issue each of those customers a gift card based on

Problem to solve:

A high-end department store has chosen five customers at random and will issue each of those customers a gift card based on the total the customer spent that month. The value of the gift card will be the percentage of the amount spend for that customer thus increasing the total they are credited spending. For example, Jeremy has spent $145.42 on purchases but was given a gift card worth 34.06% of the $145.42 spent ($49.53)

  • DOWNLOAD the html file Assignment_8_Initial
  • Most of the code is completed for you.Follow the directions in the comments that appear right before the functions/array declarations. These comments will guide you in developing the code.
  • Look through the entire program BEFORE beginning to program.
  • Create parallel arrays for:

oNames-will hold five names

oAmount spent-will be a randomly generated value between 0 and 500

oGift card amount-will be a randomly generated value between-and 50

oTotals-will be the sum of the amount spent and the amount determined by the gift card

percentage * the amount spent.

  • Create function code to
  • ogetAmountSpent()-no parameters
  • ogetGift()-no parameters
  • ogetSumTotals-array parameter
  • ofindLargeCustomer-array parameter
  • Modify the total button
  • oCalculate the total of all customer totals
  • oCalculate the average of the customer totals
  • oIdentify thepersonwho has the highest current

oPlace the results into the correct text boxes formatted properly.Be sure to remember:

  • You will generate HTML comments to add your name, section, and TA name. This will (should) NOT be visible in the document on the web browser.
  • Your assignment is to create the JavaScript to calculate the values as described above. Follow the directions in the comments that appear right before the functions/arrays. These comments will guide you through the code.
  • Variable names should be descriptive.
  • Indentation should be correct.
  • Your program code should be easy to follow.

Assignment_8_Initial code:

Preferred Customers

body {background-color: cadetblue; font-family: optima;

color: MidnightBlue; text-align: center}

p { font-size: 30px}

button {font-size: 20px; background-color: coral}

input { font-size: 20px}

/*

This function returns a random number between 0 and 500.

This is the amount the preferred customer has spent.

The number returned is rounded to 2 decimal places.

Use toFixed(2)

*/

function getAmountSpent(){

// your code goes here

}

/*

This function returns a random number between 0 and 50.

This is the percent the person will receive as a bonus.

The number returned is rounded to 2 decimal places.

Use toFixed(2)

*/

function getGift(){

}

/*

This function will return the sum of the elements in array a.

You will be passing the array that holds your totals to

the parameter a. Be sure to treat the values in a as numbers.

*/

function getSumTotals(a){

}

/*

This function will find and return the POSITION of

the largest value in its parameter variable, array a.

*/

function findLargePosition(a){

//your code

}

/*

Assign to a new array (names) 5 string values represneting the customers.

Use an initializer list to do this. {...names...}

*/

var names = //your array initializer list here

/*

Create a new array (spent) with length 5;

You must use a loop and call the function getAmountSpent

to assign to each element in the array the appropriate random value.

Make sure the values you are assigning are numbers.

and round the values to 2 decimal places.

*/

var spent = //create your array

//your code tofill the array

/*

Create a new array (gifts) with length 5;

You must use a loop and call the function getGift

to assign to each element in the array an appropriate random value.

Make sure the values you are assigning are numbers

*/

var gifts = //create your Array

//your code to fill array

/*

Create a new array (totals) with length 5;

You must use a loop ato fill the array.

The values in the array represent:

Amount spent + the very generous gift.

The values in gifts are numbers between 0 and 50.

You need to treat them as percentages (divide by 100)

in order to calculate the correct values for your

array (totals). You will add that percent of the amount

spent to their current amount spent to calculate their

total. (1 + gifts[i]/100)*spent[i]

Make sure that the values assigned to totals are

Numbers rounded to 2 decimal places. toFixed(2) helps.

*/

var totals = //create your new array here.

//code to fill array Totals

Gift Cards to Preferred Customers

Total Amount:

Average Customer Total:

Preferred Customer with Largest Total:

image text in transcribed
Learning Objectives: This assignment is designed to practice: 1. Writing and calling functions 2. Creating arrays a With initializer lists b By assigning values within a loop 3. Using loops 4. Using Math.random() 5. Using Number() to ensure values are treated as numbers and not strings 6. Using concatenation to have textbox values appear as currency or percents 7. Using toFixed(2) to round to 2 decimal places 8. Reading and understanding the use of comments Overview: You are provided an HTML program. Your responsibility is to insert the appropriate JavaScript statements in the correct locations that will solve the problem discussed below, You are also to comment the html file with the requested information per the requirements. Read the comments carefully as they direct you in writing the code. Your tasks (requirements): DOWNLOAD the html file Assignment_8_Initial. Save on your computer as Assignment_8_Answer. Most of the code is completed for you. Follow the directions in the comments that appear right before the functions/array declarations. These comments will guide you in developing the code. Look through the entire program BEFORE beginning to program. Create parallel arrays for: o Names - will hold five names O Amount spent - will be a randomly generated value between 0 and 500 O Gift card amount - will be a randomly generated value between - and 50 o Totals - will be the sum of the amount spent and the amount determined by the gift card percentage * the amount spent. . Create function code to o getAmountSpent() - no parameters O getGift() - no parameters O getSumTotals - array parameter o findLargeCustomer - array parameter Modify the total button o Calculate the total of all customer totals o Calculate the average of the customer totals o Identify the person who has the highest current 2

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

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

Recommended Textbook for

Modern Dental Assisting

Authors: Doni Bird, Debbie Robinson

13th Edition

978-0323624855, 0323624855

Students also viewed these Programming questions

Question

Define ISI.

Answered: 1 week ago

Question

Describe the Indian public distribution system.

Answered: 1 week ago

Question

Write a note on AGMARK.

Answered: 1 week ago

Question

Plan merit and demerits ?

Answered: 1 week ago