Ask Question
27 April, 02:46

Write a program to calculate the average of all scores entered between 0 and 100. Use a sentinel-controlled loop variable to terminate the loop. After values are entered and the average calculated, test the average to determine whether an A, B, C, D, or F should be recorded. The scoring rubric is as follows: A-90-100; B-80-89; C-70-79; D-60-69; F < 60

+1
Answers (1)
  1. 27 April, 03:07
    0
    import java. util. Scanner;

    public class ANot {

    public static void main (String[] args) {

    Scanner in = new Scanner (System. in);

    int n = 0;

    int sum=0;

    while (n<=100) {

    System. out. println ("enter the next score");

    sum = sum+in. nextInt ();

    n++;

    }

    double average = sum/n;

    if (average>90) {

    System. out. println ("Record A");

    }

    else if (average>80 && average<90) {

    System. out. println ("Record B");

    }

    else if (average>70 && average<80) {

    System. out. println ("Record C");

    }

    else if (average>60 && average<70) {

    System. out. println ("Record D");

    }

    else{

    System. out. println ("Record F");

    }

    }

    }

    Explanation:

    Using Java programming language:

    Prompt user to input the 100 scores. Use a while statement with the condition while (n<100) since n has been initialized to zero. Increment n after each iteration. create a sum variable outside the while loop and initialize to zero Add the value entered at each iteration to the sum variable average = sum/n Use multiple if/elseif and else statements to output what should be recorded according to the given rubic.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Write a program to calculate the average of all scores entered between 0 and 100. Use a sentinel-controlled loop variable to terminate the ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers