Write Code Competency Practice

Write a program to input test scores until the user enters a score greater than or equal to 100. For each score, if the score is an even score less than 60, get that person’s name and print a message saying the score is even and less than 60. After you exit the loop, print the number of odd scores over 80, the highest score less than 70, and the average score in the 80s.

 

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>”);

Write a program to get test scores from the user until a 0 test score is entered. For each test, tell if it is below 50. If it is, get the name of that student. After you finish getting all the scores, print out the average of all the even scores, the highest odd score, and the number of scores in the 80s.

SOLUTION:

get a test score
while there are still tests left
      if it is below 50
            tell the user it is below 50
            get this person’s name
      if this score is even
            add this test score to the total for even test scores
            add 1 to the count of even scores
      if this score is odd
            if this is the highest odd score so far
                 change the high odd score to this score
      if this score is greater that 79 and less than 90
            add 1 to the count for scores in the 80s

     get the next score

print the total of even scores divided by the count of even scores
print the highest odd score
print the count of scores in the 80s

Write a program to get test scores from the user until a 0 test score is entered. For each score, tell if it is an odd or an even score. If the score is over 90, tell the user “good job” for that test. When you finish entering all the scores, Print the average of all the odd scores, the highest even score, and how many scores were below 60.

SOLUTION IN ENGLISH (ONE EXAMPLE)

get a test score

while the score is not a 0
     if the score is odd
          print the score is odd
     if the score is even
          print the score is even
     if the score is over 90
          tell the user good job
     if the score is odd
          add 1 to the odd scores total
          add this score to the total for odd scores
     if this score is even
          if this is the highest even score so far
                rename the highest even score as this score
     if this score is less than 60
          add 1 to the scores less than 60
     get the next score

print the sum of the odd scores divided by the number of odd scores
print the highest even scores
print the number of scores less than 60

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>