logo CodeStepByStep logo

Histogram

Language/Type: Java collections ArrayList
Related Links:

Write a console program named Histogram that reads a list of exam scores from an input file that contains one score per line and then displays a histogram of those numbers, divided into the ranges 0-9, 10-19, 20-29, and so forth, up to the range containing only the value 100. For example, suppose a file midtermscores.txt contains the numbers shown below (one per line):

73 58 73 93 82 62 80 53 93 52 92 75 65 95 23 100 75 38 80 77 92 60 98 95 62 87 97 73 78 72 55 58 42 31 78 70 78 74 70 60 72 75 84 87 62 17 92 78 74 65 90

Given this file, your program should be able to generate the following sample run (with user input shown like this):

File: midtermscores.txt
00-09:
10-19: *
20-29: *
30-39: **
40-49: *
50-59: *****
60-69: *******
70-79: *****************
80-89: ******
90-99: **********
  100: *
Class: Write a complete Java class.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.