Question as bellow:
Write a program to implements an interview scheduler.
These are the requirements for the interview scheduler:
A prompt asks the executive secretary to input the time for the first interview, and then a loop continues to prompt for input of subsequent interview, and then a loop continues to prompt for input of subsequent interview times. Input terminates when the secretary enters a time at or after 5:00 pm. A loop executes pop() operations until the queue is empty. Each iteration outputs the time that the appointment begins, along with the amount of the time available for the director to carry out the interview. When the queue becomes empty, the time for the last interview is the difference between the office-closing time of 5:00 pm. and the prior starting time for the last interview.
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
public class TimeSchedule {
public static void main(String args[]) {
Queue TimeList = new LinkedList();
DateFormat df = new SimpleDateFormat("HH:mm");
df = DateFormat.getDateInstance(DateFormat.LONG);
boolean loopstoper = false;
try {
Date limit = df.parse("17:00");
Scanner scan = new Scanner(System.in);
String time = scan.nextLine();
Date date = df.parse(time);
while (loopstoper == false) {
if (date.before(limit)) {
TimeList.offer(date);
} else {
loopstoper = true;
while (TimeList.size() > 0) {
System.out.println("Time Schedule = " + TimeList.poll());
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
please help me check my work correct or not because it cannot run in Netbean software? Is that answer match that question? Thanks for your helping.