I have to write a program for two users, a school admin and a student. The admin must first enter a password and enter 15 courses by day Mon-Fri (1-5) and time Morning, Afternoon, Evening (1-3) into an array. Then the student can enter the day and time and view courses available. If the admin has not entered a course for that day, it should display 'Course not available'. This is the code I have:
But I have two problems: when I try to enter a day and time for the student, this error shows up: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 3 out of bounds for length 3 at pkg.Exercise3.main(Exercise3.java:72)
which I know means my array is out of bounds, but I'm not sure why as I entered numbers like 2 for day and 3 for time! Also, I cannot figure out how to display the message that the 'course is not available' if the array has not been filled.
Any help would be much appreciated! Thanks!