Write a program that allows students to schedule appointments at either 1,2,3,4,5 as days of the week; 1 for Monday, 2 for Tuesday and so on. Use an array of five strings to store the names for the time slots. Write a loop that iterates as long as the array has a free space. Within a try block, allow the user to enter a day and a name. If the day is free, put the name in the array. If the day is not free, throw an Exception. If the day is not valid, throw another exception. Use catch block for each different kind of exception.
Write a program that allows students to schedule appointments at either 1,2,3,4,5 as days of the week; 1 for Monday, 2 for Tuesday and so on. Use an array of five strings to store the names for the time slots. Write a loop that iterates as long as the array has a free space. Within a try block, allow the user to enter a day and a name. If the day is free, put the name in the array. If the day is not free, throw an Exception. If the day is not valid, throw another exception. Use catch block for each different kind of exception.
Ex:
Enter Day: 1
Monday is available, enter Name: Tomas
[Tomas, , , , ]
Enter Day: 3
Wednesday is available, enter Name: Sheldon
[Tomas, ,Sheldon, , ]
Enter Day: 3
Wednesday is not available, choose other day: 2
Tuesday is available, enter Name: Raj
[Tomas,Raj,Sheldon, , ]
Enter Day: 4
Thursday is available, enter Name: Leonard
[Tomas,Raj,Sheldon,Leonard, ]
Enter Day: 0
Invalid Day
Enter Day: A
Invalid Day
Enter Day: 5
Friday is available, enter Name: Howard
[Tomas,Raj,Sheldon,Leonard,Howard]
Enter Day: 1
Schedule is full //END
Step by step
Solved in 2 steps with 1 images