Question: Write a program that reads a file containing an arbitrary number of text integers that are in the range 0 to 99 and counts how

 Write a program that reads a file containing an arbitrary number

Write a program that reads a file containing an arbitrary number of text integers that are in the range 0 to 99 and counts how many fall into each of eleven ranges. The ranges are 0-9, 10-19. 20-29,..., 90- 99 and an eleventh range for "out of range." Each range will be represented by a cell of an array of ints. Find the correct cell for each input integer using integer division. After reading in the file and counting the integers, write out a histogram that shows the range of each bin, the number of integers that fell into that bin, and a horizontal row of stars that shows the number in each bin. Put a space after every ten stars. Assume that there will be no more than 50 integers in each category. If a category has more than that, just write out 50 stars. (A better program would automatically adjust how many integers each star represents.) Ask the user for the name of the input file and create a Scanner to read the file. This should not be elaborate. A hard-coded file name is not acceptable. Again, listing 5.10 on p. 242 of the text will be useful. You will need methods hasNexInt () and nextInt () from class scanner. The input file will consist of an arbitrary number of text integers and no other characters but white space: 23 45 91 105 1 0 23 78 84 45 1 52 57 93 -1 4 56 99 23 (Some integers in the above are out of range.) Don't make any assumptions about the size or format of the file. Design: Make this a console application, i.e. a program with a static main that does most of the work and possibly some static helper functions. Running: Create several testing files to check that your program works. Of course, I will test your program with my test files

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!