Question: Your Tasks - in Java Complete the following steps to solve the problem: Use an array of six elements of type Strings to store students'
Your Tasks - in Java
Complete the following steps to solve the problem:
- Use an array of six elements of type Strings to store students' names that get valid appointments for the time slots.
- Write a loop that iterates as long as the array has free space, meaning there are still appointments available.
- Within a try block, allow the user to enter a time and a name. Read the times as simple integers, with values from 1 to 6.
- If the time is free, meaning it does not have a name in that particular element, put the name in the array. If the time is not free, throw a TimeInUseException.
- If the time is not valid, throw an InvalidTimeException.
- Use a catch block for each different kind of exception.
- Once all appointments are made, display the schedule.
- If you implement all the required methods properly, the program should generate outputs similar to the following:

Enter a time for appointment, from 1 to 6: 2 Enter your name: Albert Enter a time for appointment, from 1 to 6: 5 Enter your name: Mina Enter a time for appointment, from 1 to 6: 2 Enter your name: Mary Wrong choice. This slot is taken. Try another time! Enter a time for appointment, from 1 to 6: 9 This time is not valid Enter a time for appointment, from 1 to 6: 1 Enter your name: Mary Enter a time for appointment, from 1 to 6: 3 Enter your name: John Enter a time for appointment, from 1 to 6: 4 Enter your name: Paul Enter a time for appointment, from 1 to 6: 3 Enter your name: Al Wrong choice. This slot is taken. Try another time! Enter a time for appointment, from 1 to 6: 5 Enter your name: Al Wrong choice. This slot is taken. Try another time! Enter a time for appointment, from 1 to 6: 6 Enter your name: Emma Schedule is full. No appointment available! Schedule is: 1pm: Mary 2pm: Albert 3pm: John 4pm: Paul 5pm: Mina 6pm: Emma Press any key to continue
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
