The objectives of this question are

  • to practice arrays in Java.
  • to practice methods in Java.

You are required to develop a simple application system to implement a patient queue for seeing a doctor in a clinic. The system should maintain a list of up to 25 patients. The patient names are stored in the queue and the system will allow the clinic staff to perform the following tasks:

  • Queue a Patient
  • Call Next Patient
  • List Patients in Queue
  • Search Patient ‘s Queue Position

Your program should include the following:

The method displayMenu()displays the following menu:

MENU
1. Queue a Patient
2. Call Next Patient
3. List Patients in Queue
4. Search A Patient’s Queue Position
0. EXIT

The method queuePatient()queues a patient.

  • This method receives as the parameters: the array of patient names, a patient name and a count that keeps track of the number of patients queuing in the system.
  • If queue has reached full capacity, the method displays a message Queue is full.
  • If queue has not reached full capacity, the method should put the name of the patient into the queue, update the count and displays a message in this format: name is in position #n where name is the patient name entering the queue and n is a number starting from 1.
  • This method returns the value of count.

The method callNextPatient()displays the name of the patient first in the queue.

  • This method receives as the parameters: the array of patient names and the count of patients.
  • If the queue is empty, the method displays a message: Queue is empty
  • If the queue is not empty, the method displays Calling name where name is the first patient name in the queue. The displayed name is then removed from the queue and the count adjusted accordingly.
  • The value of count is returned.

The method listPatients() displays the names of the patients in order.

  • This method receives as the parameters: the array of patient names and the count of patients.
  • If the queue is empty, the method displays a message: Queue is empty
  • If the queue is not empty, the method displays a heading Queue List and each queue position (starting from 1) in the format n) name where n is the queue position and name is the corresponding patient name.

The method searchPatient()search for a particular patient in the patient queue.

  • This method receives as the parameters: the array of patient names, a patient name and the count of patients.
  • The method checks each name in the array to determine whether the name appears.
  • The method returns the queue position of that name if it appears in the queue. Queue position starts from 1.
  • Otherwise the method returns -1.

The main() method to perform the following:

  • create an array for patient queue.
  • display a menu to allow clinic staff to select an option and call the appropriate method to perform task according to the user's selection (you MUST use switch statement here).
  • prompts and reads patient name for option 1 and 4
  • for option 4, displays either
    • name is not in the queue. or
    • name is in #n position of the queue. where name is the patient name being queried and n is the corresponding queue position
  • Repeat the process of displaying menu and processing the option until the staff chooses to exit the program.

Submit the program listing together with a screenshot showing the output to convince your tutor that your program is working. In your run, you should demonstrate that each of the options is working. Display your name and student number in the first line of your program output. (

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.