/* * This program will compute the average of a set of test scores and * output to the console each score and the distance that score is from * the mean. * * The program will first prompt the user for the number of scores to be entered. * * @author: Anthony Larrain */ import java.util.Scanner; class DifferenceFromMean{ public static void main(String [] args ) { Scanner input = new Scanner(System.in); System.out.println("How many scores will you be entering ?"); int numberOfScores = input.nextInt(); // create an array of integers int [] scores = new int[numberOfScores]; for(int i = 0; i < numberOfScores; i++){ System.out.println("Enter score " + (i+1)); scores[i] = input.nextInt(); } double mean = ArrayTool.mean(scores); System.out.println("The mean is " + mean); //Print each score and the distance from the mean.. for(int j = 0; j < scores.length; j++){ System.out.println( scores[j] + "\t--> " + (scores[j] - mean) ); } } }