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
WRITE THE ENGLISH BEFORE THE CODE
GET A SCORE
WHILE THE SCORE IS LESS THAN 100
— IF THE SCORE IS LESS THAN 60 AND THE SCORE IS EVEN
——— OUTPUT SCORE IS LESS THAN 60 AND EVEN
———- GET THE NAME FROM THE PERSON
— IF THE SCORE IS ODD AND GREATER THAN 80
——— COUNT IT
— IF SCORE IS LESS THAN 70
——— IF SCORE IS THE HIGHEST SO FAR
—————– USE THIS SCORE AS THE NEW HIGHEST
— IF THE TEST SCORE IS IN THE 80S
———- COUNT IT
———–SUM IT
— GET NEXT TEST SCORE
PRINT THE NUMBER OF ODD SCORES OVER 80
PRINT THE HIGHEST SCORE LESS THAN 70
PRINT THE AVERAGE OF ALL SCORES IN THE 80S
CODE: Comes directly from ENGLISH above! THINK in ENGLISH, then translate
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>”);