Q:

Develop a JavaScript Program That Will Determine The Gross Pay For Each Of Three Employees. Remaining Question Is Given Below

0

Develop a JavaScript program that will determine the gross pay for each of three employees. The company pays “straight time” for the first 40 hours worked by each employee and pays “time and a half” for all hours worked in excess of 40 hours. You are given a list of the employees of the company, the number of hours each employee worked last week and the hourly rate of each employee. Your program should input this information for each employee, determine the employee’s gross pay and output XHTML text that displays the employee's gross pay. Use prompt dialogs to input the data

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

<html>
<head>
<title>Pay Day </title>
<script type="text/javascript">
<!--
var e1;
var r1;
var e2;
var r2;
var e3;
var r3;
e1 = window.prompt("Enter Number of Hours Employee1 worked last week:");
r1 = window.prompt("Enter hourly wage rate for Employee1:");
e2 = window.prompt("Enter Number of Hours Employee2 worked last week:");
r2 = window.prompt("Enter hourly wage rate for Employee2:");
e3 = window.prompt("Enter Number of Hours Employee3 worked last week:");
r3 = window.prompt("Enter hourly wage rate for Employee3:");
var cal1;
if(parseInt(e1)>40)
{
var extrahours = parseInt(parseInt(e1)-40);
var extrarate= parseInt(r1) + (parseInt(r1) / 2 );
cal1= ((40 * parseInt(r1))+ (extrahours * parseInt(extrarate)));
}
else
{
cal1=parseInt(e1) * parseInt(r1);
}
document.writeln( "<h1> Employee1 Gross Wage is: " + cal1 + "</h1>" );
var cal2;
if(parseInt(e2)>40)
{
var extrahours1 = parseInt(parseInt(e2)-40);
var extrarate1= parseInt(r2) + (parseInt(r2) / 2 );
cal2= ((40 * parseInt(r2))+ (extrahours1 * parseInt(extrarate1)));
}
else
{
cal2=parseInt(e2) * parseInt(r2);
}
document.writeln( "<h1> Employee2 Gross Wage is: " + cal2 + "</h1>" );
var cal3;
if(parseInt(e3)>40)
{
var extrahours2 = parseInt(parseInt(e3)-40);
var extrarate2= parseInt(r3) + (parseInt(r3) / 2 );
cal3= ((40 * parseInt(r3))+ (extrahours2 * parseInt(extrarate2)));
}
else
{
cal3=parseInt(e3) * parseInt(r3);
}
document.writeln( "<h1> Employee3 Gross Wage is: " + cal3+ "</h1>" );
// -->
</script>
</head>
<body>
<h1><center>Pay Day</center>
<hr />
<p> Click Refresh(F5) or reload to run this script again</p>
</body>
</html>

 

Output:

Employee1 Gross Wage is: 360

Employee2 Gross Wage is: 350

Employee3 Gross Wage is: 375

Pay Day

Click Refresh(F5) or reload to run this script again

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now