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:

  1. Use an array of six elements of type Strings to store students' names that get valid appointments for the time slots.
  2. Write a loop that iterates as long as the array has free space, meaning there are still appointments available.
  3. 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.
  4. 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.
  5. If the time is not valid, throw an InvalidTimeException.
  6. Use a catch block for each different kind of exception.
  7. Once all appointments are made, display the schedule.
  8. If you implement all the required methods properly, the program should generate outputs similar to the following:

Your Tasks - in Java Complete the following steps to solve the

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

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!