Ask Question
8 March, 07:09

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. 8 March, 10:56
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers