<!DOCTYPE html public "-//w3c//dtd html 4.0 Transitional//en">

<HTML>

<HEAD>
<TITLE>Payroll</TITLE>
<META name="GENERATOR" content="Arachnophilia 4.0">
<META name="FORMATTER" content="Arachnophilia 4.0">
<CENTER><H2>Exercise 9.14</H2></CENTER><P>
<table width=300 align=center>
  <tr>
  	<td align=center>
  	  Enter data for three (3) employees.  These data are name, hours worked, and rate of pay.
    </td>
  </tr>
</table><p>

<script language="JavaScript">
<!-- ;

var name, hours, rate, ot, gross;

// Output headers
document.writeln( "<TABLE align='center' border='0' cellspacing='2' cellpadding='6'>" );
document.writeln( "<TR bgcolor='lightblue'><TD ><B>Employee Name</B></TD>" );
document.writeln( "<TD ><B>Hours</B></TD><TD ><B>Rate</B></TD>" );
document.writeln( "<TD ><B>Gross Pay</B></TD></TR>" );

for( var i=0; i<3; i++ )
{
  // Get an employee's data
  name = prompt( (i+1)+":  Enter employee's name:","name");
  hours = parseInt( prompt( (i+1)+":  Enter employee's number of hours worked:","0") );
  rate = parseFloat( prompt( (i+1)+":  Enter employee's rate of pay:","0.00") );

  //Calculate gross
  if ( hours > 40 ) {
    ot = (hours-40) * rate * 1.5;
    gross = (40 * rate) + ot;
  }
  else {
    gross = hours * rate;
  }

  // output data for one employee
  document.writeln( "  <TR><TD >"+name+"</TD><TD align='right'>"+hours+"</TD>" );
  document.writeln( "  <TD align='right'>"+rate+"</TD><TD align='right'>"+gross+"</TD></TR>" );
}
document.writeln( "</TABLE>" );

// end hide -->
</script>
</HEAD>

<BODY>

 <P><b><-- Click on the lab you want to run.</b><P>

<a href="9_14src.html">View Source</a><p>


</BODY>

</HTML>