header

Lab 14

In this assignment, you will modify the program you wrote for homework 12. Your modified program is to be organized differently and you are to use an array of student objects to store all of the data in the file. Your program is to include two additional private methods: one to read all of the data into an array of student objects and a second to print a report based on the data in the array. In your actionPerformed method, you will invoke these two new methods when the user opens a student data file.

The capacity of the array of student records is MAXSIZE which is a constant identifier. The value of MAXSIZE should be 100.

The report generated by this application does NOT include the average SAT scores! The report is like the report you generated in Lab 10.

I have given you the code that you will need in the section of the actionPerformed method that deals with user interaction with the text field and the Open button. All you have to do now is implement the other two methods (readStudents and displayReport).

     // This is the try clause in the section of code that
    // is executed when the user clicks the Open button.

    try
    {
        // Open the input file as you did in Homework 12
    
        Student[] stuList = new Student[MAXSIZE];
        int numStudents = readStudents(stuList, infile);
        infile.close();
        displayReport(numStudents, stuList);
        txaReport.setCaretPosition(0);
    }
    
    /**
     * Read the student data from the specified scanner into the
     * specified array of students and return the number of records
     * read.
     * 
     * @param list the array of students
     * @param sc the scanner
     * 
     * @return the number of student records read from the scanner
     */
    private int readStudents(Student[] list, Scanner sc)
    {
        You are to implement this method.
    }
    
    /**
    * Display a table showing the SAT scores of the students in the
    * specified array.
    * 
    * @param n the number of students in the list
    * @param list the array of students
    */
    private void displayReport(int n, Student[] list)
    {
        You are to implement this method.
    } 
}

Submitting Your Work

Submit your Lab14.java application as an attachment to an email message whose subject is "Lab14".