Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Can someone fix my code to make it display the output below? import java.util.Sc

ID: 3568765 • Letter: C

Question

Can someone fix my code to make it display the output below?

import java.util.Scanner;
class OurDate
{
   private int month;
   private int day;
   private int year;

   public OurDate()
   {
       month = 01;
       day = 01;
       year = 1901;
   }


   public OurDate (int mm, int dd, int yyyy)
   {
       month = mm;
       day = dd;
       year = yyyy;
   }

   public void inputMonth() {

       Scanner input = new Scanner (System.in);
       System.out.println("Enter the month(0-12): ");
       month = input.nextInt();

   }

   public void inputDay() {

       Scanner input = new Scanner (System.in);
       System.out.println("Enter the day (0-31): ");
       day = input.nextInt();
   }

   public void inputYear() {

       Scanner input = new Scanner (System.in);
       System.out.println("Enter the year (0-2500): ");
       year = input.nextInt();


   }

   //Add accessor methods to get day,month and year of date.
   public int getDay()
   {
       return day;
   }
   public int getMonth()
   {
       return month;
   }
   public int getYear()
   {
       return year;
   }

   public void displayDate() {
       System.out.println ("Inital Date is "+ month + "/" + day + "/" + year);
   }

   public void display() {
       System.out.println ("The Date is "+ month + "/" + day + "/" + year);

   }
}// end of class Ou

class OurTime
{
   private int hours;
   private int minutes;
   private int seconds;

   public OurTime()
   {
       hours = 0;
       minutes = 0;
       seconds = 0;
   }

   public OurTime (int h, int m, int s)
   {
       hours = h;
       minutes = m;
       seconds = s;
   }

   public void setHoursFromUser( )
   {
       Scanner input = new Scanner (System.in);
       System.out.println("Enter the hours(0-23): ");
       hours = input.nextInt();
       while (hours < 0 || hours > 23) {
           System.out.println("Error...invalid hours....Enter the hours(0-23): ");
           hours = input.nextInt();
       }
   }// end setHours

   public void setMinutesFromUser( )
   {
       Scanner input = new Scanner (System.in);
       System.out.println("Enter the minutes (0-59): ");
       minutes = input.nextInt();
       while (minutes < 0 || minutes > 59)
       {
           System.out.println("Error...invalid minutes....Enter the minutes(0-59): ");
           minutes = input.nextInt();
       }
   }// end setMinutes

   public void setSecondsFromUser( )
   {
       Scanner input = new Scanner (System.in);
       System.out.println("Enter the seconds (0-59): ");
       seconds = input.nextInt();
       while (seconds < 0 || seconds > 59) {
           System.out.println("Error...invalid seconds....Enter the seconds(0-59): ");
           seconds = input.nextInt();
       }
   }// end setSeconds


   public void display()
   {
       System.out.println (hours + ":" + minutes + ":" + seconds);
   }// end of display

   public int calcTotalSeconds()
   {
       return ((hours*60+minutes)*60+seconds);
   }// end calcTotalSeconds

}// end of class Time
class Event
{
     
   private OurDate ourDate;
   private OurTime ourTime;
   private String eventDescription;

   public Event(OurDate ourDate,OurTime ourTime, String eventDescription)
   {
       this.ourDate=ourDate;
       this.ourTime=ourTime;
       this.eventDescription=eventDescription;
   }

   //return date

   public OurDate getDate()
   {
       return ourDate;
   }


   public void displayEvent()
   {
       ourDate.displayDate();
       ourTime.display();
       System.out.println("Event Description "+eventDescription);
   }
}

class Planner
{

   private int SIZE;
   private Event events[];
   private int count;

   public Planner()
   {
       SIZE=500;
       events=new Event[SIZE];
       count=0;
   }

   public void addEvent()
   {
     
       OurDate ourDate=new OurDate();
       ourDate.inputDay();
       ourDate.inputMonth();
       ourDate.inputYear();
     
       OurTime ourTime=new OurTime();
     
       ourTime.setHoursFromUser();
       ourTime.setMinutesFromUser();
       ourTime.setSecondsFromUser();
       Scanner reader=new Scanner(System.in);
       System.out.println("Enter description");
       String description=reader.nextLine();
     
       Event event=new Event(ourDate, ourTime, description);
       if(count<SIZE)
           events[count]=event;
     
       //increament event count
       count++;
   }

   //display events for a day.
   public void displayDayActivities()
   {
       OurDate searchDate=new OurDate();
       searchDate.inputDay();

       for (int eventIndex = 0; eventIndex < count; eventIndex++)
       {
           OurDate date=events[eventIndex].getDate();
           if(searchDate.getDay()==date.getDay())
               events[eventIndex].displayEvent();
       }
   }//end of the method displayDayActivities

   //display events for a month.
   public void displayMonthActivities()
   {
       OurDate searchDate=new OurDate();
       searchDate.inputMonth();

       for (int eventIndex = 0; eventIndex < events.length; eventIndex++)
       {
           OurDate date=events[eventIndex].getDate();
           if(searchDate.getMonth()==date.getMonth())
               events[eventIndex].displayEvent();
       }
   }//end of the method displayMonthActivities

   //display events for a month.
   public void deleteActivity()
   {
       OurDate searchDate=new OurDate();
       searchDate.inputDay();
       searchDate.inputMonth();
       searchDate.inputYear();
     
       boolean deleted=false;
    

       for (int eventIndex = 0; eventIndex < events.length; eventIndex++)
       {
           OurDate date=events[eventIndex].getDate();
           if( searchDate.getDay()==date.getDay()&&
               searchDate.getMonth()==date.getMonth()&&
               searchDate.getYear()==date.getYear())
               //set event to null
           {
                   events[eventIndex]=null;
                   deleted=true;
           }
       }
     
       if(deleted)
           System.out.println("Event is deleted");
       else
           System.out.println("Event is not found");
     
   }//end of the method displayMonthActivities

}
//Event planner java program that allows
//user to menu choice to add activity, display
//activity for a day and activties for a month
//and delete the activity in a planner and 0 to quit
//Assign4.java
public class MyClass
{
   public static void main(String[] args)
   {

       //To read user choice
       int userChoice;
       //scanner to read user input
       Scanner reader=new Scanner(System.in);
       //create an instance of Planner
       Planner planner=new Planner();

       do
       {
           System.out.println("1: Add an activity to planner");
           System.out.println("2: Display activities for a day");
           System.out.println("3: Display activites for a week");
           System.out.println("4: Delete an activity");
           System.out.println("0 to quit");
           System.out.println("Enter your choice");
           userChoice=reader.nextInt();

           if(userChoice==0)
           {
               System.out.println("Program exit");
               System.exit(0);
           }

           switch (userChoice)
           {
               case 1:
                   planner.addEvent();
                   break;
               case 2:
                   planner.displayDayActivities();
                   break;
               case 3:
                   planner.displayMonthActivities();
                   break;
               default:
                   System.out.println("Invalid choice");
                   break;
           }

       }while(true);
   }


}

I want it to display this:

Enter 1 to add an activity to planner;   2 to display activities for a day; 3 to display activites for a week; 4 to delete an activity; 0 to quit: 3

Enter date to start display from:

Enter month: 11

Enter day: 4

Enter year: 2014

Your activities for the week starting 2014/11/4 are:

Your activities for 2014/3/4 are:

     2014/11/4 18:30 Work

Your activities for 2014/11/5 are:

     2014/11/5 10:0 Coordinator meeting

Your activities for 2014/11/6 are:

Your activities for 2014/11/7 are:

Your activities for 2014/11/8 are:

Your activities for 2014/11/9 are:

Explanation / Answer

import java.util.Scanner;

class OurDate {

private int month;
private int day;
private int year;

public OurDate() {
month = 01;
day = 01;
year = 1901;
}

public OurDate(int mm, int dd, int yyyy) {
month = mm;
day = dd;
year = yyyy;
}

public void inputMonth() {

Scanner input = new Scanner(System.in);
System.out.println("Enter the month(0-12): ");
month = input.nextInt();

}

public void inputDay() {

Scanner input = new Scanner(System.in);
System.out.println("Enter the day (0-31): ");
day = input.nextInt();
}

public void inputYear() {

Scanner input = new Scanner(System.in);
System.out.println("Enter the year (0-2500): ");
year = input.nextInt();

}

//Add accessor methods to get day,month and year of date.
public int getDay() {
return day;
}

public int getMonth() {
return month;
}

public int getYear() {
return year;
}

public void displayDate() {
System.out.println("Inital Date is " + month + "/" + day + "/" + year);
}

public void display() {
System.out.println("The Date is " + month + "/" + day + "/" + year);

}
}// end of class Ou

class OurTime {

private int hours;
private int minutes;
private int seconds;

public OurTime() {
hours = 0;
minutes = 0;
seconds = 0;
}

public OurTime(int h, int m, int s) {
hours = h;
minutes = m;
seconds = s;
}

public void setHoursFromUser() {
Scanner input = new Scanner(System.in);
System.out.println("Enter the hours(0-23): ");
hours = input.nextInt();
while (hours < 0 || hours > 23) {
System.out.println("Error...invalid hours....Enter the hours(0-23): ");
hours = input.nextInt();
}
}// end setHours

public void setMinutesFromUser() {
Scanner input = new Scanner(System.in);
System.out.println("Enter the minutes (0-59): ");
minutes = input.nextInt();
while (minutes < 0 || minutes > 59) {
System.out.println("Error...invalid minutes....Enter the minutes(0-59): ");
minutes = input.nextInt();
}
}// end setMinutes

public void setSecondsFromUser() {
Scanner input = new Scanner(System.in);
System.out.println("Enter the seconds (0-59): ");
seconds = input.nextInt();
while (seconds < 0 || seconds > 59) {
System.out.println("Error...invalid seconds....Enter the seconds(0-59): ");
seconds = input.nextInt();
}
}// end setSeconds

public void display() {
System.out.println(hours + ":" + minutes + ":" + seconds);
}// end of display

public int calcTotalSeconds() {
return ((hours * 60 + minutes) * 60 + seconds);
}// end calcTotalSeconds

}// end of class Time

class Event {

private OurDate ourDate;
private OurTime ourTime;
private String eventDescription;

public Event(OurDate ourDate, OurTime ourTime, String eventDescription) {
this.ourDate = ourDate;
this.ourTime = ourTime;
this.eventDescription = eventDescription;
}

//return date
public OurDate getDate() {
return ourDate;
}

public void displayEvent() {
ourDate.displayDate();
ourTime.display();
System.out.println("Event Description " + eventDescription);
}
}

class Planner {

private int SIZE;
private Event events[];
private int count;

public Planner() {
SIZE = 500;
events = new Event[SIZE];
count = 0;
}

public void addEvent() {

OurDate ourDate = new OurDate();
ourDate.inputDay();
ourDate.inputMonth();
ourDate.inputYear();

OurTime ourTime = new OurTime();

ourTime.setHoursFromUser();
ourTime.setMinutesFromUser();
ourTime.setSecondsFromUser();
Scanner reader = new Scanner(System.in);
System.out.println("Enter description");
String description = reader.nextLine();

Event event = new Event(ourDate, ourTime, description);
if (count < SIZE) {
events[count] = event;
}

//increament event count
count++;
}

//display events for a day.
public void displayDayActivities() {
OurDate searchDate = new OurDate();
searchDate.inputDay();

for (int eventIndex = 0; eventIndex < count; eventIndex++) {
OurDate date = events[eventIndex].getDate();
if (searchDate.getDay() == date.getDay()) {
events[eventIndex].displayEvent();
}
}
}//end of the method displayDayActivities

//display events for a month.
public void displayMonthActivities() {
OurDate searchDate = new OurDate();
searchDate.inputMonth();
searchDate.inputDay();
searchDate.inputYear();

  
System.out.println("Your activities for the week starting "+searchDate.getYear()+"/"+searchDate.getMonth()+"/"+searchDate.getDay()+" are:");
for (int weekDays = 0; weekDays < 7; weekDays++) {
for (int eventIndex = 0; eventIndex < count; eventIndex++) {
OurDate date = events[eventIndex].getDate();
if (searchDate.getDay()+weekDays == date.getDay()
&& searchDate.getMonth() == date.getMonth()
&& searchDate.getYear() == date.getYear()) {
System.out.println("Your activities for "+date.getYear()+"/"+date.getMonth()+"/"+date.getDay()+" are:");
events[eventIndex].displayEvent();
}

}
}

}//end of the method displayMonthActivities

//display events for a month.
public void deleteActivity() {
OurDate searchDate = new OurDate();
searchDate.inputDay();
searchDate.inputMonth();
searchDate.inputYear();

boolean deleted = false;

for (int eventIndex = 0; eventIndex < events.length; eventIndex++) {
OurDate date = events[eventIndex].getDate();
if (searchDate.getDay() == date.getDay()
&& searchDate.getMonth() == date.getMonth()
&& searchDate.getYear() == date.getYear()) //set event to null
{
events[eventIndex] = null;
deleted = true;
}
}

if (deleted) {
System.out.println("Event is deleted");
} else {
System.out.println("Event is not found");
}

}//end of the method displayMonthActivities

}
//Event planner java program that allows
//user to menu choice to add activity, display
//activity for a day and activties for a month
//and delete the activity in a planner and 0 to quit
//Assign4.java

public class MyClass
{
public static void main(String[] args)
{

//To read user choice
int userChoice;
//scanner to read user input
Scanner reader=new Scanner(System.in);
//create an instance of Planner
Planner planner=new Planner();

do
{
System.out.println("1: Add an activity to planner");
System.out.println("2: Display activities for a day");
System.out.println("3: Display activites for a week");
System.out.println("4: Delete an activity");
System.out.println("0 to quit");
System.out.println("Enter your choice");
userChoice=reader.nextInt();

if(userChoice==0)
{
System.out.println("Program exit");
System.exit(0);
}

switch (userChoice)
{
case 1:
planner.addEvent();
break;
case 2:
planner.displayDayActivities();
break;
case 3:
planner.displayMonthActivities();
break;
default:
System.out.println("Invalid choice");
break;
}

}while(true);
}


}