package grades; /** * @author mlizarra * */ public class GradesService { final int NUMSTUDENTS = 4; String[] students; char[] grade; public GradesService ( ) { students = new String [] {"Mary", "Joe", "Sally", "Tim"}; grade = new char [] {'A', 'B', 'C', 'D'}; } // end constructor public char getStudentGrade (String student) { for (int i = 0; i < NUMSTUDENTS; i++) { if (student.equals(students[i])) return grade[i]; } return 'Z'; } // end getStudentGrade public String getStudent (int studentID) { return students[studentID]; } // end getStudent public String[] getStudents ( ) { return students; } // end getStudents public static void main(String[] args) { GradesService gs = new GradesService(); for (int i = 0; i < gs.NUMSTUDENTS; i++) { System.out.println("Student: " + gs.getStudent (i) + "\tGrade: " + gs.getStudentGrade(gs.getStudent(i))); } } // end main } // end class GradesService