32 lines
878 B
HTML
32 lines
878 B
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
|
|
<html>
|
|
<head>
|
|
<title>Example 3.9</title>
|
|
<script>
|
|
function paycheck()
|
|
{
|
|
var rate = parseInt(prompt("What is the employee's pay rate?"," "));
|
|
var hours = parseInt(prompt("How many hours did the employee work this week?"," "));
|
|
if (hours <= 40 || rate >= 20)
|
|
var pay = rate * hours;
|
|
else
|
|
{
|
|
var overtime = rate * 1.5 * (hours- 40);
|
|
var regular = rate * 40;
|
|
var pay = overtime + regular;
|
|
}
|
|
document.write("<p>Your paycheck this week will be $ " + pay + ".</p>");
|
|
}
|
|
</script>
|
|
</<head>
|
|
<body>
|
|
<table align ="center" width ="70%"><tr><td>
|
|
<h1> </h2>
|
|
<h1>Calculating the Paycheck</h1>
|
|
<h3>Click the button to calculate a paycheck with a compound condition</h3>
|
|
<p><input type="button" id="paycheck" value="calculate the paycheck" onclick="paycheck();" /></p>
|
|
</td></tr></table></body>
|
|
</html>
|
|
|