Question: Please use java and priority queue using heaps We would like to implement boarding of passengers in an airplane. Passengers arrive belonging to different classes

Please use java and priority queue using heaps

We would like to implement boarding of passengers in an airplane. Passengers arrive belonging to different classes in the cabins, can be elderly, can have infants with them, or belong to the armed services. Each of the passenger is provided a priority depending on the conditions described. A passenger with a higher priority (indicated by a small number) is boarded before passengers with lower priority, ignoring the order in which they arrive; hence using a normal queue would not be sufficient. Using a priority queue to keep track of the order of boarding is useful in this scenario.

Construct the program using the following guidelines:

Create a Java Class for passengers. The data fields in the Class should include First Name, Last Name, Date of Birth, Boarding category and Priority.

Simulate incoming passengers with varied degree of boarding class and priority. Higher boarding class should be reflected by lower priority. Range priorities from 1 to 20. For example, Traveling with infant is priority 1, Elderly is priority 5, Armed Services is priority 10, First Class is priority 15 and Economy class is priority 20.

Add the passengers to the priority queue when they arrive based on the priority.

If there are more than one passenger with the same priority, service is first come first serve.

Implement the program to handle 15 passengers over a simulated time period of 10 minutes.

Assume it takes 20 seconds to board any passenger. Once a passenger is been attended, other passengers have to wait even the ones that arrive with higher priority.

Print out the details of the passengers in the order in which they arrived as well as the order in which they were boarded.

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!