CS 1401 Assignment #12

Date Assigned: Monday, April 24, 2006 or Tuesday, April 25, 2006.

Due Date: correspondingly, Monday, May 1, 2006, or Tuesday, May 2, 2006, before the beginning of your lab section.

Goals: to learn how to use arrays of objects.

Points: This assignment is worth a total of 20 points. No late assignments will be accepted, but credit will be given for partially completed assignments turned in on time.

Assignment: This assignment is a continuation of Assignment 11 about computing GPA in Computer Science. As in that assignment, for each student, all the classes that this student took and the corresponding grades are stored in a file. The first line of this file contains the student's name; every other line contains the catalog number of the class and the grade that the student received in this class. For example, for John Johnson, this file may take the following form:

John Johnson
MATH 3111 A
CS 1401 B
CS 3195 A
To compute the GPA, we must take all the grades in CS classes, multiply each grade by the number of hours in the corresponding class (the number of hours is the second digit of the class number), add the overall number of points, and divide this number by the total number of hours in CS classes. For example, for John Johnson, we have: Overall, the student earned 12 + 4 = 16 points, and he took 4 + 1 = 5 credit hours -- so his GPA is 16 / 5 = 3.2.

The difference with the previous assignment is that instead of two arrays of numbers, we will now have arrays of objects.

Define a Java class ClassGrade; each object of this Java class must have a field subject, a field courseNumber (you may want to make it a string), and a field grade (a character). For example, for the object corresponding to John Johnson taking CS 1401, the field subject should contain CS, the field courseNumber should contain 1401, and the field grade should contain B. Use encapsulation; in other words, make sure that these fields are private and are only accessible via methods.

Write an application that:

Use a for-loop to compute the overall number of CS credit hours and the overall number of CS points.

Deliverables: as announced in the labs.