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

This is a group project (max. 2 students) A Salesperson working for Jumbo Electr

ID: 3779402 • Letter: T

Question

This is a group project (max. 2 students) A Salesperson working for Jumbo Electronics on a weekly basis. The salesperson regular pay is calculated by multiplying pay rate per hour times number of hours worked per week. As bonus, the company pays the Salesperson 5% commission on his or her sales. Assume that the the Salesperson has to pay the following deductions City tax, which is 7% of his gross pay salary Saving, which is 3% of his gross pay Health insurance premium, which is 75 dirhams per week (75*7) Develop a JavaScript application that should accept/read the following inputs Salesman Name Total Sales Number of hours worked Pay rate per hour In addition the application should calculate and display the following outputs: Name of Salesperson The Gross pay for the salesperson

Explanation / Answer

Save this program in a html file i.e. a file with .html extension and run it in browser.

<html>

<head>
   <title>Javascript Application</title>
   <script>
       function calculate(){

           // get the input values from html
           var salesman_name = document.getElementById("salesman_name").value;
           var total_sales = parseFloat(document.getElementById("total_sales").value);
           var hours_worked = parseFloat(document.getElementById("hours_worked").value);
           var pay_rate = parseFloat(document.getElementById("pay_rate").value);

           // calculate regular pay
           var regular_pay = pay_rate * hours_worked;

           // calculate gross pay
           var gross_pay = regular_pay + ((5/100)*total_sales);

           //calculate deduction
           var deduction = ((7/100)*gross_pay) + ((3/100)*gross_pay) + (75*7)

           // calculate the inhand salary after subtracting the deductions
           var inhand_salary = gross_pay - deduction;

           // The output string is formatted accordingly
           var output = "<center>Name of Salesman : <b>" + salesman_name + "</b><br>Gross Pay : <b>" + gross_pay.toFixed(2) + "</b><br>In-Hand Salary : <b>" + inhand_salary.toFixed(2) + "</center></b>";

           document.getElementById("result").innerHTML = output;

       }

       function clear_result(){
           document.getElementById("salesman_name").value = "";
           document.getElementById("total_sales").value = "";
           document.getElementById("hours_worked").value = "";
           document.getElementById("pay_rate").value = "";
           document.getElementById("result").innerHTML = "";
       }
   </script>
</head>

<body>
   <center>
   <form>
       <table>
           <tr>
               <th colspan="2"><h2>Jumbo Electronics Salesman Pay Calculator</h2></th>
           </tr>
           <tr>
               <td>Salesman Name : </td><td><input type="text" name="salesman_name" id="salesman_name" value=""></td>
           </tr>
           <tr>
               <td>Total Sales : </td><td><input type="text" name="total_sales" id="total_sales" value=""></td>
           </tr>
           <tr>
               <td>Number of Hours worked : </td><td><input type="text" name="hours_worked" id="hours_worked" value=""></td>
           </tr>
           <tr>
               <td>Pay rate per hour : </td><td><input type="text" name="pay_rate" id="pay_rate" value=""></td>
           </tr>
           <tr>
               <td colspan="2"><center><br/><button type="button">Calculate</button> <button type="button">Clear</button></center></td>
           </tr>
       </table>
   </form>
   <div id="result">
   </div>
   </center>
</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