Write Code Example Problem
Write a program to get scores from a user until a test score 100 or higher is entered. If an even score less than 60 is entered, tell the user this fact and get the name of that student. After the loop is exited, find the number of odd scores over 80, the highest score less than 70,and the average score in the 80s
ANSWER IS BELOW
<html>
<body>
<script type=”text/javascript”>
var eventotal = evencount = highodd = eightycount = 0;
testscore = prompt(“enter the first test score”,””);
testscore = parseInt(testscore);
while (testscore < 100 )
{
if ((testscore< 60) && (testscore%2 == 0))
{
document.write(“this even score is less than 60″ + “<p>”);
name = prompt(“what is this persons name?”,””);
}
if ((testscore % 2) == 1) && (testscore > 80) )
{
count = count + 1;
}
if (testscore < 70)
{
if (testscore>high)
{
high = testscore;
}
}
if ((testscore > 79) && (testscore < 90))
{
ec = ec + 1;
esum = esum + testscore;
}
testscore = prompt(“enter the next test score or 0 to exit”,””);
testscore = parseInt(testscore);
}
document.write(“the number of odd scores over 80 is ” + count + “<p>”);
document.write(“the highest score less than 70 is ” + high + “<p>”);
document.write(“the average score in the 80s is ” + esum/ec + “<p>”);
</script>
</body>
</html>