ASDV-WebDev/Semester 1/Assignments/JavaScript/ch03/ex_3_6.html

32 lines
874 B
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Example 3.6</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 overtime = rate * 1.5 * (hours- 40);
var regular = rate * 40;
var pay = overtime + regular;
}
else
var pay = rate * hours;
document.write("<p>Your paycheck this week will be $ " + pay + ".</p>");
}
</script>
</<head>
<body>
<table align ="center" width ="70%"><tr><td>
<h1>&nbsp;</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>