Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Programming Project: Dental appointment exercise if you are using 5th edition of the text book, it is P9.1 on page 459 (chapter 9) if you

Programming Project: Dental appointment exercise if you are using 5th edition of the text book, it is P9.1 on page 459 (chapter 9) if you are using 6th edition of the text book, it is P9.3 on page 461 (chapter 9) Hint: There should be appointments already created and you are simply asking the users for a date to check against them. There are several ways that you can approach this question. The example below is just one way of solving this problem. Write a method OccursOn inside each of the sub classes that checks whether the appointment occurs on that date (OneTime), day (Day) or month (Month). Ask the user to enter a date to check (for example, 2006 10 5), and ask to user if they want to check against OneTime, Day or Month appointment. Based on what the user selected, OccursOn inside each of the sub class should run and display any matching appointment and associated descriptions. For OneTime subclass, OccursOn need three inputs (Year, Month and Day) to validate, for Day subclass, OccursOn needs one input (Day) to validate, and for Month subclass, OccursOn need one input (Month) to validate. OccursOn is different for different subclasses.

use this code AppointmentDemo.

import java.util.Scanner; public class AppointmentDemo { public static void main(String[] args) { Appointment[] appointment = new Appointment[5]; appointment[0]= new Onetime(25,12,2017," Root Canal"); appointment[1]= new Monthly(25,12,2017," Teeth Cleaning"); appointment[2]= new Daily(25,12,2017," Filling"); appointment[3]= new Onetime(13,12,2017," Crown"); appointment[4]= new Monthly(15,12,2017," Dentures"); Scanner keyboard = new Scanner(System.in); System.out.println("Please input the day of the appointment (1-31) "); int day = keyboard.nextInt(); System.out.println("Please input the month of the appointment (1- 12) "); int month = keyboard.nextInt(); System.out.println("Please input the year of the appointment "); int year = keyboard.nextInt(); System.out.println(day +" "+ month+" " + year); for (int i =0; i <5; i++){ if (appointment[i].occursOn(day, month, year)==true){ System.out.println("You have a" + appointment[i].getDesc() + " appointment on: " + day + " "+ month+ " " + year); } } } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design And SQL For DB2

Authors: James Cooper

1st Edition

1583473572, 978-1583473573

More Books

Students also viewed these Databases questions