Question: Need help resolving run error with this code: package appointmentbook; import java.util.Scanner; public class Appointment { private String description; private int year; private int month;
Need help resolving run error with this code:
package appointmentbook;
import java.util.Scanner;
public class Appointment {
private String description;
private int year;
private int month;
private int day;
public Appointment(int year, int month, int day, String description) {
this.year = year;
this.month = month;
this.day = day;
this.description = description;
}
public int getYear()
{
return year;
}
public int getMonth()
{
return month;
}
public int getDay()
{
return day;
}
public boolean occursOn(int year, int month, int day) {
return (year == this.year) && (month == this.month) && (day == this.day);
}
public String toString()
{
return description;
}
}
class Onetime extends Appointment {
public Onetime(int year, int month, int day, String description)
{
super(year, month, day, description);
}
}
class Daily extends Appointment {
public Daily(int year, int month, int day, String description) {
super(year, month, day, description);
}
public boolean occursOn(int year, int month, int day)
{
if (year > getYear())
{
return true;
}
if (year == getYear())
{
if (month > getMonth())
{
return true;
}
if (month == getMonth())
{
if (day >= getDay())
{
return true;
}
}
}
return false;
}
}
class Monthly extends Appointment {
public Monthly(int year, int month, int day, String description)
{
super(year, month, day, description);
}
public boolean occursOn(int year, int month, int day)
{
if (year
{
return false;
}
if (month
{
return false;
}
return day == getDay();
}
}
class Main
{
public static void main(String[] args) {
Appointment[] appointments = new Appointment[1];
appointments[0] = new Monthly(2023, 2, 14, "See The Dentist");
System.out.println("Enter a new appointment (year, month, day) to calendar " + "appointments: ");
Scanner in = new Scanner(System.in);
int year = in.nextInt();
int month = in.nextInt();
int day = in.nextInt();
for (int i = 0; i
if (appointments[i].occursOn(year, month, day)) {
System.out.println(appointments[i]);
}
}
}
}

terminated> Main [Java Application] CiUsers\jamos_pops\Downloadsleclipse-java-2022-12-R-win32-x86_64leclipselpluo inter a new appointment (year, month, day) to calendar appointments: 2023,03,12 Exception in thread "main" java.util.InputMismatchException at java.base/Java.util.Scanner, throhEor (Scanner.java:939 at java.base/java, uti1, scanner.next (Scanner.java:1594) at Java.base/ Java. Itti1. Scanner. nexteInt Scanner. java: 2258 at java.base/java. uti1. Scanner.next Ine Scanner.java:2212 at appointmentbook. Hein.main (Appointment.java:108
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
