Write a program named TestScoreList that accepts eight int values representing student test scores. Display each of the values along with a message that indicates how far it is from the average. An example of how the results should be output is as follows:


Test # 0: 89 From average: 6

Test # 1: 78 From average: -5

Respuesta :

ijeggs

Answer:

import java.util.Scanner;

public class TestScoreList {

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       int [] testScores = new int[8];

       int sumScores =0;

       for(int i=0; i<testScores.length; i++){

           System.out.print("Enter Test scores: ");

           testScores[i]= in.nextInt();

           sumScores+=testScores[i];

       }

       double ave = sumScores/8;

       System.out.println("The Average is: "+ave);

       for(int i =0; i<testScores.length; i++){

           System.out.println("Test # "+i+": "+testScores[i]+" From Average "+

                   (testScores[i]-ave));

       }

   }

}

Explanation:

Using Java programming Language

Create an array of size 8

Prompt user to enter test scores values using a for loop

Using another for loop, find sum and average

Using a third for loop, format output as required by the question using string concatenation

See code output attached.

Ver imagen ijeggs