Question: Create a method, getStudentId that retrieves the index in the array associated with the name of a student. Create a driver that will enroll 5

Create a method, getStudentId that retrieves the index in the array associated with the name of a student. Create a driver that will enroll 5 students. Call the getStudentId to retrieve the ID for one of the 5 enrolled students. (JAVA)

existing code:

public class GradeBook{ private enum EnrollmentStatus {OPEN, FULL}; private EnrollmentStatus enrollment; private int occupiedSlots; private int maxSlots; private String[] names; public GradeBook(int maxSlots){ this.occupiedSlots = 0; this.maxSlots = maxSlots; enrollment = EnrollmentStatus.OPEN; names = new String [maxSlots]; } public int getMaxSlots(){ return maxSlots; } public int getAvailbleSlots(){ return maxSlots - occupiedSlots; } public boolean enroll(String name){ if(enrollment == EnrollmentStatus.FULL) return false; else { names[occupiedSlots++] = name; if(occupiedSlots>=maxSlots) enrollment = EnrollmentStatus.FULL; } return true; } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!