package StudentPkg; /** * StudentGrades.java * Created on September 20, 2001, 11:03 AM * This class processes student grades * * @author Stuart Hansen * @version **/ import java.util.*; import java.io.*; public class StudentGrades { private Vector studentVector = new Vector(); // A vector containing all the students // Create an empty set of student grades */ public StudentGrades() {} /** add a student to the class list **/ public void add(Student s) { studentVector.add(s); } /** returns the number of students in the object */ public int getStudentCount() {return studentVector.size();} /** returns the student at index i in the vector */ public Student getStudent(int i) {return (Student)studentVector.get(i);} /** returns the average of the student averages **/ public double getAverage () { double sum = 0.0; for (Iterator i= studentVector.iterator(); i.hasNext();) { sum += ((Student)(i.next())).getAverage(); } return sum/studentVector.size(); } /** returns the exam average for the given exam **/ public double getExamAverage(int exam) { if (exam == 1) return getExam1Average(); else if (exam == 2) return getExam2Average(); else if (exam ==3) return getExam3Average(); return 0; } /** returns the average for exam 1 **/ public double getExam1Average() { double sum = 0.0; for (int i=0; i