// Reads a file of test scores and shows a histogram of the score distribution. import java.io.*; import java.util.*; public class Histogram { public static void main(String[] args) throws FileNotFoundException { Scanner input = new Scanner(new File("midterm.txt")); int[] scores = new int[101]; while (input.hasNextInt()) { int score = input.nextInt(); scores[score]++; } for (int i = 0; i < scores.length; i++) { System.out.print(i + ": "); for (int j = 0; j < scores[i]; j++) { System.out.print("*"); } System.out.println(); } } }