Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

DNA Databases

Authors: Stefan Kiesbye

1st Edition

0737758910, 978-0737758917

Students also viewed these Databases questions

Question

1. Which position would you take?

Answered: 1 week ago