Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program named (Scheduler.java) that allows students to schedule appointments at either 1, 2, 3, 4, 5, or 6 oclock pm. The program should

Write a program named (Scheduler.java) that allows students to schedule appointments at either 1, 2, 3, 4, 5, or 6 oclock pm.

The program should accept up to 6 appointments, making sure that there is no time conflict or an invalid time slot is requested.

You will need to do the following: o Declare an array appointments that can hold six Strings to store the names for the time slots.

o Declare a counter appointmentsMade to count how many appointments were made.

o Write a loop that iterates as long as the array has a free space.

o Two of the classes that you need to include are declared below and you need to write the code for the third class according to the given instructions:

1. public class TimeInUseException extends Exception{

/** * Creates a new instance of TimeInUseException */ public TimeInUseException(String reason) { super(reason); }

2. public class InvalidTimeException extends Exception{

/** * Creates a new instance of InvalidTimeException */

public InvalidTimeException(String reason) {

super(reason); } }

3. public class Scheduler: o Will include the main() method with instance variables declarations and try and catch blocks.

o Within the try block, allow the user to enter his/her name and the requested time slot.

o If the time slot is not already occupied (i.e. free), put the users name in the appointments array.

o You will need to write three catch blocks that will catch the following exceptions:

InvalidTimeException - that will display the message "Sorry, that is not a legal time

TimeInUseException - that will display the message "Sorry, that time is already in use

Exception - that will display the message "Bad time format, should just be an integer"

o If the time is not free, throw a TimeInUseException.

o If the time is not valid, throw an InvalidTimeException.

o If the user enters a time that is not an integer, throw Exception.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro Database Migration To Azure Data Modernization For The Enterprise

Authors: Kevin Kline, Denis McDowell, Dustin Dorsey, Matt Gordon

1st Edition

1484282299, 978-1484282298

More Books

Students also viewed these Databases questions

Question

Define a model.

Answered: 1 week ago

Question

25.0 m C B A 52.0 m 65.0 m

Answered: 1 week ago