Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A grade text file was provide that has one integer number per line representing

ID: 3662999 • Letter: A

Question



A grade text file was provide that has one integer number per line representing a student's grade in the class. These numbers are not sorted but they are bound between 0 and 100 (inchusive) Using an array, you must count the frequency of each grade value and print it to the standard output as a horizontal histogram. You must also label the range of each histogram bar and allow the user to indicate what size interval they would like the histogram to be made with. The out should look like this What interval size would you like? 100 911000DD0On 90-81 0000000000000000000000000 80-71 00O0O0OL000000 70-61 000O00ODO00000000 60-51 0000000 50-41 0000 40-31 GuD000

Explanation / Answer

import java.util.Scanner; import java.io.FileInputStream; import java.io.FileNotFoundException; public class GradeHistogram{ public static void main(String[] args) throws Exception { Scanner gradeFile = new Scanner(new FileInputStream("grades.txt")); int counter = 0; while (gradeFile.hasNextLine()) { gradeFile.nextLine(); counter++; } int[] grades = new int[counter]; System.out.println("Grades loaded!"); System.out.println("What bucket size would you like?"); Scanner output = new Scanner(System.in); for (int i = 0; i