Question: Write a Java code for the following problem statement : Problem Statement: Dr. Kumar runs a hospital for senior citizens which sees a large number

Write a Java code for the following problem statement :

Problem Statement: Dr. Kumar runs a hospital for senior citizens which sees a large number of patients coming in everyday. In order to avoid inconvenience to the aged patients, the rule is that the oldest patient is seen first by the doctor. As the patients keep coming and registering, they are added to a priority list from which patient names are taken out for consultation. Since it is not practical to implement this system using pen and paper, an appointment software has to be developed. This software will use Heaps as data structures to keep track of incoming patients and prioritizing them. The application should be capable to: 1. Take the name of the patient along with his/her age and create a patient ID for the patient. 2. Insert the patient id in the priority list based on the age of the patient. 3. Display the next patient ID in line to meet the doctor. Remove this patient from the priority list. Implement the above problem statement in JAVA using HEAPS covered in the sessions. Data Structures to be used: PatientRecord: A doubly linked list containing the patient information including the patient name, age and the patient number (assigned by the program). ConsultQueue: A max heap using arrays containing the patient id in the sequence of the next consultation based on the age of the patient. Following are the operations to be performed. 1. int registerPatient(String name, int age): Precondition: An input file input.txt is ready and contains the initial set of patient names and ages. Effect: This function registers the name and age of the patient entering the hospital and assigns them an ID that is returned to the calling function. When the program is executed for the first time, the patient details are loaded from an input file. This is analogous to the list of patients present at the hospital before the registration counter opens. Thereafter, new patients will be input with the help of menu options and console-based input. 2. void enqueuePatient(Patient_ID): Precondition: none Effect: This function assigns the patient a place in the max heap depending on their age. The patient id is inserted into the max heap. This function should be called every time a new patient is added to

the program and should run a sort after adding the patient id to keep the consultation queue updated as per the age condition. 3. void nextPatient(): Precondition: Both the patient DLL and Heap are not empty Effect: This function prints the patient_ID and name of the patient that is next in line to meet the doctor. This function is called either through a menu option of every time a new patient registers and the patient is added to the queue. 4. void dequeuePatient(Patient_ID): Precondition: Both the patient DLL and Heap are not empty Effect: This function removes the patient ID from the queue that has consulted the doctor and updates the queue. The function is called from the nextPatient function itself after the next patients name is displayed. 5. void displayQueue(): Precondition: Both the patient DLL and Heap are not empty Effect: This function displays all the remaining patients in the queue in the following format: , , , where sequence number is the order in which the patient will meet the doctor. This output should be written in an output.txt file. 6. Include all other functions required to support the operations of these basic functions. Also ensure to include a proper exit sequence from the program. Input: The input may be taken as sequence of ages through a test file input.txt Example: Pradeep, 45 Surya, 60 Ajit, 55 Mary, 64 Radha, 56 Output: Depending on the option chosen, the correct output should be displayed

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!