Question: Design a class that calculates statistics on data in a file. We expect the file to contain grades represented by integer values, one per line.
Design a class that calculates statistics on data in a file. We expect the file to contain grades represented by integer values, one per line. If you encounter a value that is not an integer, you should throw an exception, print a message to the console, skip that value, and continue processing. Store the grades that you read in an ArrayList so that all grades are available for retrieval. You should also have, at a minimum, methods that return the average grade, the highest grade, the lowest grade, and one that returns all the grades as an array of letter grades. The constructor should accept the name of the data (input) file.
Test this class with an application that creates two objects sending two different text files as the data file. Create these text files. One that contains all integers and will not throw an exception and one that contains some values that will throw an exception. Make sure the test application calls each method for each object displaying the highest, lowest, and average grades, as well as the list of letter grades.
You may add other functionality you consider relevant but be sure to include what is listed above at a minimum.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
