Question
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:
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:
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