31 lines
1.0 KiB
HTML
Executable File
31 lines
1.0 KiB
HTML
Executable File
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
|
|
<html>
|
|
<head>
|
|
<title>Example 3.4</title>
|
|
<script>
|
|
function getScore()
|
|
{
|
|
var basicScore = parseInt(prompt("What was the student's initial score?"," "));
|
|
var extraQuestion = prompt("Did the student do Q. 21 (yes or no)?"," ");
|
|
if (extraQuestion == "yes")
|
|
var points = parseInt(prompt("How many points did the student earn on Q. 21?"," "));
|
|
else
|
|
var points = parseInt(prompt("How many points did the student earn for a study guide?"," "));
|
|
var score = basicScore + points;
|
|
document.write("<h1> </h1>");
|
|
document.write("<p> </p>");
|
|
document.write("<p> The student's score, with any extra credit, is " + score + "%.</p>");
|
|
}
|
|
</script>
|
|
</<head>
|
|
<body>
|
|
<table align ="center" width ="70%"><tr><td>
|
|
<h1> </h2>
|
|
<h1>Student Score</h1>
|
|
<h3>Click the button! </h3>
|
|
<p><input type="button" id="score" value="Enter the exam score?" onclick="getScore();" /></p>
|
|
</td></tr></table></body>
|
|
</html>
|
|
|