Ask Question
14 August, 02:48

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

+5
Answers (1)
  1. 14 August, 03:43
    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?
Get 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 there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers