Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A large company pays its salespeople on a commission basis. Thesalespeople recei

ID: 662565 • Letter: A

Question

A large company pays its salespeople on a commission basis. Thesalespeople receive $200 per week, plus 9 percent of their grosssales for that week. For example, a salesperson who sells $5000worth of merchandise in a week receives $200 plus 9 percent of$5000, or a total of $650. You have been supplied with a list ofthe items sold by each salesperson. The values of these items areas follows

Item Value

1 239.99

2 129.75

3 99.95

4 350.89

Develop a script that inputs one saleperson's items sold for last week, calculates the salesperson's earnings and outputs HTML5 text that displays the salesperson's earnings.

Need in JavaScript

Explanation / Answer

<head>
<script type = "text/javascript">

var Total = 0;
var Earnings;
var items_sold = 0;
var num;
var user_input;


while ( items_sold < 4 )
{
++items_sold;
user_input = window.prompt("Enter the number of pieces of item "+ items_sold+" sold last week:" );
num = parseInt( user_input );

if ( items_sold == 1 )
Total= Total + num * 239.99;
else if ( items_sold == 2 )
Total= Total + num * 129.75;
else if ( items_sold == 3 )
Total= Total + num * 99.95;
else if ( items_sold == 4 )
Total= Total + num * 350.89;
}

Earnings = .09 * Total + 200;

document.writeln( "This salesperson earned " + Earnings + " this week" );

</script>
</head>
</html>

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote