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

Using HTML & Java Script 10.10 Use a one-dimensional array to solve the followin

ID: 3595433 • Letter: U

Question

Using HTML & Java Script

10.10 Use a one-dimensional array to solve the following problem: A company pays its salespeople on a commission basis. The salespeople receive $200 per week plus 9 percent of their gross sales for that week. For example, a salesperson who grosses $5000 in sales in a week receives $200 plus 9 per- cent of $5000, or a total of $650. Write a script (using an array of counters) that obtains the gross sales for each employee through an HTML5 form and determines how many of the salespeople earned salaries in each of the following ranges (assume that each salesperson's salary is truncated to an integer amount): a) $200-299 b) $300-399 c) $400-499 d) $500-599 e) $600-699 f) $700-799 g) $800-899 h) $900-999 i) $1000 and over

Explanation / Answer

<head>
   <title> Salary Ranges</title>
   <meta http-equiv="content-type"
       content="text/html;charset=utf-8" />
   <meta http-equiv="Content-Style-Type" content="text/css" />

  
   <script type="text/javascript">
      
       var rangeOfSales = new Array( 9 );
       var salary = 200;
       var grossSales = 0;
       var commission = 0;

       for (var i = 0; i < rangeOfSales.length; ++i)
           rangeOfSales[ i ] = 0;


       function calculate(grossSales)
       {
           commission = grossSales * 0.09;
           salary = salary + commission;
      
           if(salary >= 200 && salary <= 299)
               rangeOfSales[0]++;
           if(salary >= 300 && salary <= 399)
               rangeOfSales[1]++;
           if(salary >= 400 && salary <= 499)
               rangeOfSales[2]++;
           if(salary >= 500 && salary <= 599)
               rangeOfSales[3]++;
           if(salary >= 600 && salary <= 699)
               rangeOfSales[4]++;
           if(salary >= 700 && salary <= 799)
               rangeOfSales[5]++;
           if(salary >= 800 && salary <= 899)
               rangeOfSales[6]++;
           if(salary >= 900 && salary <= 999)
               rangeOfSales[7]++;
           if(salary >= 1000)
               rangeOfSales[8]++;

           output();
       }

       function output()
        {
           myForm.result.value="Number of people who earned salaries in the following ranges: "+
                   "$200-$299 " + rangeOfSales[0] + " " +
                   "$300-$399 " + rangeOfSales[1] + " " +
                   "$400-$499 " + rangeOfSales[2] + " " +
                   "$500-$599 " + rangeOfSales[3] + " " +
                   "$600-$699 " + rangeOfSales[4] + " " +
                   "$700-$799 " + rangeOfSales[5] + " " +
                   "$800-$899 " + rangeOfSales[6] + " " +
                   "$900-$999 " + rangeOfSales[7] + " " +
                   "$1000 and up " + rangeOfSales[8];
                  
        }
  
</script>
</head>

<body>
   <form name = "myForm" action = "">

       <p>
           Enter Sales Amount: <br />
           <input name = "input" type = "text" />
           <input name = "Submit" type = "button" value ="Submit" /><br />
       </p>
       <p>
           <textarea name = "result" rows = "11" cols = "60">
           </textarea>
       </p>
   </form>
</body>
</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