add previous assignment
This commit is contained in:
31
Assignments/JavaScript/Chapter3Examples/public_html/ex_3_6.html
Executable file
31
Assignments/JavaScript/Chapter3Examples/public_html/ex_3_6.html
Executable file
@@ -0,0 +1,31 @@
|
||||
<!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> </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>
|
||||
|
Reference in New Issue
Block a user