A Doctor wishes you to write a program to help him schedule patient appointments
ID: 3668387 • Letter: A
Question
A Doctor wishes you to write a program to help him schedule patient appointments. He wants you to give a patient a choice between two days, then a choice between morning or afternoon, and finally a time. He than wants you to display the appointment. You will be using if-else statements as well as the JOptionPane class. • The class name should be AppointmentScheduler. • Display a good introduction screen You are to use only three showInputDialogue methods and two showMessageDialogs statements within your source code, including the program introduction. • The information from each successive data entry must be included in the next prompt. • You may choose any two days you want - have the user enter the first letter of the day (enter m for Monday), same for the time (enter m for Morning or a for Afternoon), then have the user enter a time. • You may phrase your prompts how you want. I need this in JAVA. Thank you!
Explanation / Answer
import Date.*;
import Time.*;
public class Appointment
{
private String location;
private String appointed;
private String purpose;
private int year;
private int month;
private int day;
private int hours;
private int minutes;
private int seconds;
public Appointment(int year, int month, int day, int hours, int minutes, String location, String appointed, String purpose) throws Exception
{
Date date = new Date(year, month, day);
Time time = new Time(hours, minutes);
this.year = year;
this.month = month;
this.day = day;
this.hours = hours;
this.minutes = minutes;
this.seconds = seconds;
this.location = location;
this.appointed = appointed;
this.purpose = purpose;
}
public Appointment() throws Exception
{
Date date = new Date();
Time time = new Time();
this.year = year;
this.month = month;
this.day = day;
this.hours = hours;
this.minutes = minutes;
this.seconds = seconds;
this.location = location;
this.appointed = appointed;
this.purpose = purpose;
}
public void setDate (int year, int month, int day) throws Exception
{
Date date = new Date(year, month, day);
this.year = year;
this.month = month;
this.day = day;
return;
}
public int getYear()
{
return year;
}
public int getMonth()
{
return month;
}
public int getDay()
{
return day;
}
public String getTime()
{
String result;
result = "Hour=" + hours + "minutes=" + minutes;
return result;
}
public void setTime (int hours, int seconds)throws Exception
{
Time time = new Time(hours, minutes);
this.hours = hours;
this.minutes = minutes;
return;
}
public String getAppointed()
{
return appointed;
}
public String toString()
{
return "The appointment is on:" + day + "/" + month + "/" + year + "at " + hours + ":" + minutes + " in: " + location + " with " + appointed + " scheduled for " + purpose;
}
public int compareTo(Date otherDate)
{
if (getYear() != (otherDate.getYear()))
return getYear() - (otherDate.getYear());
else if (getMonth() != (otherDate.getMonth()))
return getMonth() - (otherDate.getMonth());
else
return getDay() - (otherDate.getDay());
}
public static void main (String[]args) throws Exception
{
int comparisonResult;
Appointment aAppt = new Appointment(2016, 2, 2, 11, 42, "Suite 202", "Dr Crenshaw", "Checkup");
Appointment bAppt = new Appointment(2016, 2, 2, 12, 42, "Suite 202", "Dr Crenshaw", "Checkup");
Appointment cAppt = new Appointment(2016, 4, 4, 1, 42, "Suite 202", "Dr Crenshaw", "Checkup");
System.out.println("The appointment info : " + aAppt);
System.out.println("The appointment info : " + bAppt);
comparisonResult = aAppt.compareTo(bAppt);
if (comparisonResult == 0)
System.out.println(aAppt + "is equal to" + bAppt);
else if (comparisonResult < 0)
System.out.println(aAppt + "is less than" + bAppt);
else
System.out.println(aAppt + "is greater than" + bAppt);
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.