Write a program that will: 1.) Prompt the user for the name of a file, containing a list of....

Write a program that will:

1.)  Prompt the user for the name of a file, containing a list of records, - preceded by an int containing the number of records in the list.

      a.)  Each record will consist of a last name (String), and a gpa (double)

2.)  From the int value at the beginning of the file, create a 1-D array of Student objects, with the size of the int value.  The student object consists of a String with lastName and a double with gpa.

3.)  Load all the Student objects onto the array.

4.)  Calculate the lowest, highest, sum, and average of all the gpa’s (doubles) in the array.

5.)  Print out all the statistics:

        a.)  The student with the lowest gpa is:  xyz  with gpa of:  ###

        b.)  The student with the highest gpa is:  abc with gpa of: ###

        c.)   The average of all students’ gpa is: ###

6.)  Include exception handling for:

      FileNotFoundException, BadDataException, IOException

        Include a finally clause of try-catch block

7.)  Throw your own exception class, BadDataException, when you detect that:

      either the first number in the file is not an int

      or there are records after the last expected record in the file

      or the numbers in the file are not doubles

8.)  Create a new class, BadDataException which extends RuntimeException or Exception class.  The class is composed of a default constructor, and an overloaded constructor that receives a String message.  That constructor calls the super(message) constructor, passing it the String message.

9.)  In the comments, include a set of 3 - 5 test cases that will go through all the possible errors in the program.  For example:

a.)  Test with a file name that doesn't exist.

b.)  Use a file with bad data in it (i.e. letters instead of numbers)

c.)  Use a file that is empty

d.)  Use a file that has valid data

10.)  In the Project folder, provide a file for each of the test cases above.

Suggested menu for processing different files as input:

System.out.println("What is the type of file that you wish to read?");

System.out.println("1. Good file");

System.out.println("2. Too few recs in the counter (more recs than anticipated.)");

System.out.println("3. Too many recs in the counter (less recs than anticipated");

System.out.println("4. Non-numeric record counter.");

System.out.println("5. Invalid data in record - GPA non-numeric");

System.out.println("6. Invalid file name.");
Powered by