49 lines
1.6 KiB
HTML
49 lines
1.6 KiB
HTML
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||
|
<html>
|
||
|
<head>
|
||
|
<title>Example 4.9</title>
|
||
|
<script>
|
||
|
function getPay()
|
||
|
{
|
||
|
document.write('<table width="40%" align = "center">');
|
||
|
var name = " ";
|
||
|
var hours = 0;
|
||
|
var rate = 0;
|
||
|
var grossPay = 0;
|
||
|
var netPay = 0;
|
||
|
document.write('<tr><td>name</td><td>gross pay</td><td>net pay</td></tr>');
|
||
|
name = prompt("Enter the first employee's name:");
|
||
|
do
|
||
|
{
|
||
|
hours = parseFloat(prompt("How many hours did " + name + " work this week?"));
|
||
|
rate = parseFloat(prompt("What is " + name + "'s hourly pay rate?"));
|
||
|
if (hours > 40)
|
||
|
grossPay = (40 * rate) + ((hours - 40)*1.5*rate);
|
||
|
else
|
||
|
grossPay = hours * rate;
|
||
|
netPay = grossPay * .85;
|
||
|
document.write('<tr><td>' + name + '</td><td>$ ' + grossPay.toFixed(2) + '</td><td>$ ' + netPay.toFixed(2) + '</td></tr>');
|
||
|
name = prompt("Enter another employee's name or enter 'done' when finished:");
|
||
|
}
|
||
|
while (name != "done")
|
||
|
document.write('</table>');
|
||
|
}
|
||
|
</script>
|
||
|
</<head>
|
||
|
<body>
|
||
|
<table align ="center" width ="70%"><tr><td colspan ="2">
|
||
|
<h1> </h2>
|
||
|
<h1>Calculate Employees Paychecks</h1>
|
||
|
<p>You can enter payroll information for all employees. Paychecks are calculated as shown:</p>
|
||
|
<table width = "70%">
|
||
|
<tr><td>Gross pay for first 40 hours:</td><td>hourly rate * hours worked</td></tr>
|
||
|
<tr><td>Overtime:</td><td>overtime hours * 1.5 * hourly rate</td></tr>
|
||
|
<tr><td>Tax rate for all employees: </td><td>15% of gross pay</td></tr>
|
||
|
</table>
|
||
|
<tr><td><p> </p>
|
||
|
<p><input type="button" id="pay" value="Click to begin entering employees" onclick="getPay();" /></p>
|
||
|
</td></tr>
|
||
|
</table></body>
|
||
|
</html>
|
||
|
|