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

This is a java class Implement a superclass Appointment and subclasses Onetime,

ID: 673324 • Letter: T

Question

This is a java class

Implement a superclass Appointment and subclasses Onetime, Daily, and Monthly. An appointment
has a description (for example, “see the dentist”) and a date. Write a method occursOn(int year,

int month, int day) that checks whether the
appointment occurs on that date. For example, for
a monthly appointment, you must check whether
the day of the month matches. Then fill an array of
Appointment objects with a mixture of appointments.
Have the user enter a date and print out all appointments that occur on that date.

Explanation / Answer

AppointmentDemo.java

package com.student;

import java.util.Scanner;//package for keyboard inputting

/**

*

* @author Chegg Expert Answer

*/

class Appointment //super class{

    static int year; //static variable for sharing and accesing thru classname.variablename eg Appointment.Date

    static String month;

    static int Date;

    public void description() {

        System.out.println("see the dentist");

    }

    public void OccursOn(int year, String month, int Date) {

        this.year = year;//this.year represent current variable

        this.month = month;

        this.Date = Date;

    }

}

class OneTime extends Appointment {//sub class onetime

    @Override

    public void description() {

        System.out.println("see the dentist");

    }

    public void OccursOn(int Date) {

        this.Date = Date;

    }

}

class Daily extends Appointment {//subclass

    @Override

    public void description() {

        System.out.println("see the dentist");

    }

    public void OccursOn(int Date) {

        this.Date = Date;

    }

}

class Monthly extends Appointment{ //subclass

    @Override

    public void description() {

        System.out.println("see the dentist");

    }

    public void OccursOn(String month) {

        this.month = month;

    }

}

public class AppointmentDemo extends Appointment {

    public static void main(String args[]) {

        try{

        Appointment obj = new Appointment();

        obj.description();

        System.out.println("enter the for appointment");

        Scanner sc = new Scanner(System.in);//scanner class for keyboard inputting

        System.out.println("enter date");

        int usrdate = sc.nextInt();

        System.out.println("enter month");

        String usrmonth = sc.next();

        System.out.println("enter year");

        int usryear = sc.nextInt();

        

        obj.OccursOn(2015, "jan", 12);

         if (usrdate == Appointment.Date && usrmonth.equals(Appointment.month) && usryear==Appointment.year) {

                    System.out.println("Appontment is available on that day");

                    System.exit(1);//exit the program

        }

        else{

            System.out.println("no appointment on that day");

       System.exit(1);

        }

        obj.OccursOn(2015, "feb", 12);

         if (usrdate == Appointment.Date && usrmonth.equals(Appointment.month) && usryear==Appointment.year) {

                    System.out.println("Appontment is available on that day");

                    System.exit(1);//exit the program

        }

else{

            System.out.println("no appointment on that day");

        System.exit(1);//exit the program

        }

        obj.OccursOn(2015, "mar", 12);

         if (usrdate == Appointment.Date && usrmonth.equals(Appointment.month) && usryear==Appointment.year) {

                    System.out.println("Appontment is available on that day");

                    System.exit(1);

        }

else{

            System.out.println("no appointment on that day");

        System.exit(1);

        }

        obj.OccursOn(2015, "aprl", 12);

         if (usrdate == Appointment.Date && usrmonth.equals(Appointment.month) && usryear==Appointment.year) {

                    System.out.println("Appontment is available on that day");

                    System.exit(1);

        }

else{

            System.out.println("no appointment on that day");

        System.exit(1);

        }

        obj.OccursOn(2015, "may", 12);

         if (usrdate == Appointment.Date && usrmonth.equals(Appointment.month) && usryear==Appointment.year) {

                    System.out.println("Appontment is available on that day");

                    System.exit(1);

        }

else{

            System.out.println("no appointment on that day");

        System.exit(1);

        }

        obj.OccursOn(2015, "june", 12);

         if (usrdate == Appointment.Date && usrmonth.equals(Appointment.month) && usryear==Appointment.year) {

                    System.out.println("Appontment is available on that day");

                    System.exit(1);

        }

else{

            System.out.println("no appointment on that day");

        System.exit(1);

        }

        obj.OccursOn(2015, "july", 12);

         if (usrdate == Appointment.Date && usrmonth.equals(Appointment.month) && usryear==Appointment.year) {

                    System.out.println("Appontment is available on that day");

                    System.exit(1);

        }

else{

            System.out.println("no appointment on that day");

        System.exit(1);

        }

        obj.OccursOn(2015, "aug", 12);

         if (usrdate == Appointment.Date && usrmonth.equals(Appointment.month) && usryear==Appointment.year) {

                    System.out.println("Appontment is available on that day");

                    System.exit(1);

        }

else{

            System.out.println("no appointment on that day");

        System.exit(1);

        }

        obj.OccursOn(2015, "sep", 12);

         if (usrdate == Appointment.Date && usrmonth.equals(Appointment.month) && usryear==Appointment.year) {

                    System.out.println("Appontment is available on that day");

                    System.exit(1);

        }

else{

            System.out.println("no appointment on that day");

        System.exit(1);

        }

        obj.OccursOn(2015, "oct", 12);

         if (usrdate == Appointment.Date && usrmonth.equals(Appointment.month) && usryear==Appointment.year) {

                    System.out.println("Appontment is available on that day");

                    System.exit(1);

        }

else{

            System.out.println("no appointment on that day");

        System.exit(1);

        }

        obj.OccursOn(2015, "nov", 12);

         if (usrdate == Appointment.Date && usrmonth.equals(Appointment.month) && usryear==Appointment.year) {

                    System.out.println("Appontment is available on that day");

                    System.exit(1);

        }

else{

            System.out.println("no appointment on that day");

        System.exit(1);

        }

        obj.OccursOn(2015, "dec", 12);

         if (usrdate == Appointment.Date && usrmonth.equals(Appointment.month) && usryear==Appointment.year) {

                    System.out.println("Appontment is available on that day");

                    System.exit(1);

        }

else{

            System.out.println("no appointment on that day");

        System.exit(1);

        }

        }

        catch(Exception e)

        {

            e.printStackTrace();

        }

        finally{}

      

    }

}

Output

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote