question archive CSE 214 – Data Structures Homework 4 – Spring 2019 Homework 4 – due Sunday, May 08 2022, no later than 11:59 PM EST Problem 1: RFK Airport Imagine you work for Robert F

CSE 214 – Data Structures Homework 4 – Spring 2019 Homework 4 – due Sunday, May 08 2022, no later than 11:59 PM EST Problem 1: RFK Airport Imagine you work for Robert F

Subject:Computer SciencePrice:22.99 Bought3

CSE 214 – Data Structures Homework 4 – Spring 2019 Homework 4 – due Sunday, May 08 2022, no later than 11:59 PM EST Problem 1: RFK Airport Imagine you work for Robert F. Kennedy (RFK) Airport, a new 20 terminal airport built in the middle of the bustling state of Montana. RFK is still in the preliminary planning stages and the state of Montana wants to have a better idea of the outgoing air traffic they could expect at RFK. So, RFK’s investors hire some of the best statisticians to model the outgoing air traffic at RFK. First, these statisticians model the typical Flight out of RFK. They find that the Zoeing 373 is the most popular commercial jetliner used with a capacity of 15 Passengers; out of these 15 passengers, 2 are First Class, 3 are Business Class, 4 are premium economy, and 6 are economy. So, these statisticians decide to model each flight using the Zoeing 373 as the outgoing plane. Next, they find that each flight typically has 25 minutes to board followed by 5 minutes to depart. Finally, they talk with RFK planners for more details on how boarding and departures will operate at RFK. Each flight also has a BoardingQueue where a maximum of 10 passengers can wait before being let on the flight. At this queue, passengers are prioritized by flight class with ties in priority broken by passengerID (keep reading for more information on this ID). When boarding (dequeuing) people from this queue, if no more room exists in their class’s seats and they’re of a higher class than open seats, they can take a seat from the next lower class available. Now, here’s where you come in. These statisticians have modeled outgoing air traffic every minute using the following events and successive sub-events: 1. For each boarding flight, in ascending order based on how much time is left for boarding, a passenger is dequeued from a flight’s BoardingQueue and counted against a plane’s capacity. (P = Given) 2. For each boarding flight, in ascending order based on how much time is left for boarding, a passenger arrives at a flight’s BoardingQueue (P = Given) a. This passenger is first class (P = 0.1) b. This passenger is business class (P = 0.1) c. This passenger is premium economy (P = 0.3) d. This passenger is economy (P = 0.4) e. This passenger has COVID-19, extending all current departures and boarding by 10 minutes (i.e. if a plane is currently boarding, its allocated departing time is not extended). (P = 0.1) 3. A new flight begins boarding at RFK (P = Given) a. This flight is normal (P = 0.95) b. This flight is Air Force 1, pausing all other departures and boarding until its departure (P = 0.05) Some probabilities will be provided to you at the start of your program. Your task is, given these probabilities, to simulate outgoing air traffic at RFK as shown in the I/O examples below. You must ONLY use nextFloat() from Java.util.Random for this assignment. You cannot use any other library and you MUST set a seed given to you at the start of your program. For each event, in the order of events given above, you must call nextFloat once a minute to determine if the event occurs. If an event does occur, you must determine a successive sub-event, if applicable, by calling nextFloat once as well. Details on using nextFloat and setting a seed can be found in the Resources section of this assignment. All events are independent of each other, meaning they can all occur every minute. However, be aware that each successive sub-event is mutually exclusive, meaning they cannot happen simultaneously (e.x. we won’t have a COVID positive person who is also in first class). Any passenger who has COVID-19 is not allowed into a flight’s BoardingQueue. Due to a minute being too long, within your code, print as much as you can until user input is necessary. Every passenger is given a passenger ID equal to their arrival index (i.e. arrival index N implies this person was the Nth person to enter this particular flight’s BoardingQueue before that flight’s final departure). If all terminals are taken, refuse any new flights. If a plane becomes full, you must start departure. If a BoardingQueue is full, refuse any new passengers until space becomes available. Examples of refusal can be found in the I/O examples. No ArrayLists or Linked Lists are allowed for this assignment. Grading [100 pts total]: Your programming assignment will be graded using seeds, probabilities, and execution times only known by the TAs. Ensure your program works over a variety of different seeds/probabilities/execution times. 10 combinations of seeds, probabilities, and execution times will be tested, with each combination worth a total of 10 points. Compilation and Submission: On Blackboard, be sure to submit a SINGLE .zip file (NOT .rar, .7z, etc.) named your_studentID#_HW4.zip When decompressed, your zip file should contain only your assignment’s .java files in a single folder labeled HW4. Your program must run on its own and should not crash. Use exception handling as required. If your program does not compile, you will receive a 0 for it. You have to write all the CODE BY YOURSELF. Any form of plagiarism will result in 0 in the homework and possibly even a Q for the course. NOTE: Although your program may run well on your Integrated Development Environment (IDE) of choice (i.e. Eclipse, Visual Studio, InteliJ, etc.), your program WILL NOT be compiled or graded using any IDE. Instead, your program will be compiled on a standard Unix shell in the same directory as your decompressed HW4 folder using the following 2 commands: javac *.java java FlightSimulator Ensure that your program compiles with these two commands into a usable state. If you have any questions contact any of the TAs and/or attend office hours. Required Classes and More: The following classes are required for this problem. Each class provides a description and the specifications necessary to complete its implementation. If you feel that additional methods or variables would be useful, feel free to add them during your implementation as you see fit. However, all the variables and methods in the following specifications must be included in your homework. You should declare the data fields of the classes as private and should provide the public getter and setter methods where reasonable or required. Additionally, “fully documented classes” are classes which have enough reasonable comments and documentation for TAs and the professor to understand your implementation of this assignment. There is no strict criteria, but at minimum you must include comments that describe crucial steps of computation within your implementation. 1. Passenger Write a fully documented class named Passenger that contains parameters on the information about itself. The Person class should contain an identifying passengerID, arrival time (in minutes), and their traveling class • public Passenger() constructor and also public Passenger(…parameters as needed…) • One (enum) TravelClass: o passClass • Two int variables: o passengerID o arrivalTime 2. BoardingQueue (ArrayQueue) Write a fully documented class named BoardingQueue representing a flight’s line for boarding. • public BoardingQueue() constructor and also public BoardingQueue(…parameters as needed…) • One Passenger Array o passengerQueue[10] • Three int variables: o front o rear o size • public void enqueuePassenger(Passenger newPass) o Brief: ! Enqueues a passenger to the BoardingQueue keeping in mind their class and ID. o Parameters: ! newPass – passenger to be enqueued. o Preconditions ! None. o Postconditions ! newPass is enqueued in the BoardingQueue. o Returns ! None. o Throws ! NoRoomException - Thrown when there is no more room in the queue. • public Passenger dequeuePassenger() o Brief: ! Dequeues the next passenger from the BoardingQueue. o Parameters: ! None. o Preconditions ! None. o Postconditions ! nextPass is dequeued from the BoardingQueue. o Returns ! The dequeued passenger. o Throws ! NoPassengerException - Thrown when there is no one in the queue. 3. Flight Write a fully documented class named Flight that represents a flight out of RFK. Flight should implement the toString() method, which should print all of the Flight"s data in tabular form. • Public Flight() constructor and also public Flight(…parameters as needed…) • One String o destination • One BoardingQueue o boardQueue • Four Passenger Arrays o firstClass[2] o businessClass[3] o premiumEconomy[4] o economy[6] • Six int variables • minutesLeftBoarding • minutesLeftDeparting • firstClassInd • businessClassInd • premiumEconomyInd • economyInd • One boolean variable • boarding • public void addToFlight(Passenger boardedPass) o Brief: ! Adds a passenger to the correct passenger array o Parameters: ! Passenger boardedPass – The passenger boarding the plane. o Preconditions ! boardedPass was dequeued from the flight’s BoardingQueue. o Postconditions ! boardedPass is added to the correct passenger array. o Returns ! None. o Throws ! None. 4. FlightSimulator: Write a fully documented class named FlightSimulator. This class will be responsible for displaying a simulation of RFK’s outgoing flights. • Must contain your main method o public static void main (String [] args) • One Flight Array o flightTerminals[20] • One Random variable o randomNumberGenerator Sample Input / Output // Comment in green, input in red, output in black One Large Example: Welcome to RFK Private International Airport! Enter a seed for this simulation: 6267773456 \\ Seeds are longs Enter the probability of a passenger arrival: 0.5 Enter the probability that a passenger is dequeued: 0.7 Enter the probability that there is a new flight at RFK: 0.2 Enter how many minutes this simulation should take: 62 Starting simulation… \\ An example of what to do if no event, boarding, departure, or final departure is triggered. Minute 0 Events: Nothing to note… Currently Boarding: Nothing to note… Departing Nothing to note… Final Departures Nothing to note… Minute 1 Events: \\ When a new flight is triggered, you must stop and ask the user for its destination - A new flight to…SJC…has begun boarding! Currently Boarding: - Flight to SJC has 25 minutes to board, 0 passenger(s), and 0 person(s) waiting to board. Departing Nothing to note… Final Departures Nothing to note… \\ Here, a new passenger appears (1st passenger to board for a flight to San Jose) Minute 2 Events: - First class passenger (ID 1) on flight to SJC has entered the flight’s boarding queue! Currently Boarding: - Flight to SJC has 24 minutes to board, 0 passenger(s), and 1 person(s) waiting to board. Departing Nothing to note… Final Departures Nothing to note… \\ Here, a passenger is dequeued from a flight’s boarding queue Minute 3 Events: - First-class passenger (ID 1) on flight to SJC has boarded on a First-class seat! Currently Boarding: - Flight to SJC has 23 minutes to board, 1 passenger(s), and 0 person(s) waiting to board. Departing Nothing to note… Final Departures Nothing to note… \\ Here, multiple events happen simultaneously (NOTE: New flights happen after introducing new passengers to the BoardingQueue) Minute 4 Events: - Economy passenger (ID 2) on flight to SJC has entered the flight’s boarding queue! - A new flight to…LAX…has begun boarding! Currently Boarding: - First-class passenger (ID 1) on flight to SJC has boarded on a first-class seat! - Flight to SJC has 22 minutes to board, 1 passenger(s), and 1 person(s) waiting to board. - Flight to LAX has 25 minutes to board, 0 passenger(s), and 0 person(s) waiting to board. Departing Nothing to note… Final Departures Nothing to note… \\ Here, events for multiple flights (and other events) happen simultaneously (NOTE: introducing new passengers to the BoardingQueue happens after boarding passengers from the PassengerQueue) Minute 5 Events: - Economy passenger (ID 2) on flight to SJC has boarded on an Economy seat! - Economy passenger (ID 3) on flight to SJC has entered the flight’s boarding queue! - Premium economy passenger (ID 2) on flight to LAX has entered the flight’s boarding queue! - A new flight to…ONT…has begun boarding! Currently Boarding: - Flight to SJC has 21 minutes to board, 2 passenger(s), and 1 person(s) waiting to board. - Flight to LAX has 24 minutes to board, 0 passenger(s), and 1 person(s) waiting to board. - Flight to ONT has 25 minutes to board, 0 passenger(s), and 0 person(s) waiting to board. Departing Nothing to note… Final Departures Nothing to note… ………………………………….TIME SKIP…………………………………. \\ We have a flight preparing for departure Minute 26 Events: - Flight to SJC is now preparing for departure with 12 passengers! Currently Boarding: - Flight to LAX has 3 minutes to board, 8 passenger(s), and 1 person(s) waiting to board. - Flight to ONT has 4 minutes to board, 14 passenger(s), and 0 person(s) waiting to board. Departing Flight to SJC has 12 passengers and is 5 minutes away from departure. Final Departures Nothing to note… \\ We have a flight preparing for departure early due to a full plane Minute 27 Events: - Economy passenger (ID 15) on flight to ONT has boarded on an Economy seat! - Flight to ONT has 15 passengers and is now preparing for departure! Currently Boarding: - Flight to LAX has 3 minutes to board, 8 passenger(s), and 1 person(s) waiting to board. Departing Flight to SJC has 12 passengers and 4 minutes before departure. Flight to ONT has 15 passengers and 5 minutes before departure. Final Departures Nothing to note… \\ An example of a COVID positive person arriving at a boarding queue (NOTE: New departures and boardings are affected by extension) Minute 28 Events: - COVID positive passenger found attempting to board flight to LAX! All current departures and boarding extended by 10 minutes! - A new flight to…MEX…has begun boarding! Currently Boarding: - Flight to LAX has 11 minutes to board, 8 passenger(s), and 1 person(s) waiting to board. - Flight to MEX has 35 minutes to board, 0 passenger(s), and 0 person(s) waiting to board. Departing Flight to SJC has 12 passengers and 14 minutes before departure. Flight to ONT has 15 passengers and 15 minutes before departure. Final Departures Nothing to note… ………………………………….TIME SKIP…………………………………. \\ An example of a final departure Minute 40 Events: - COVID positive passenger found attempting to board flight to LAX! All current departures and boarding extended by 10 minutes! Currently Boarding: - Flight to LAX has 11 minutes to board, 8 passenger(s), and 1 person(s) waiting to board. - Flight to MEX has 34 minutes to board, 0 passenger(s), and 0 person(s) waiting to board. Departing - Flight to ONT has 15 passengers and 4 minutes before departure. Final Departures // Your table should look like tables from your previous assignments. These ID numbers/arrival times may not make sense, but do notice that people in each class are sorted by arrival time. Flight: RFK -> SJC \\ An example of Air Force 1 boarding from RFK Minute 41 Events: - A new flight on Air Force 1 to…DCA…has begun boarding! Currently Boarding: - Air Force 1 flight to DCA has 15 minutes to board, 0 passenger(s), and 0 person(s) waiting to board. - Boarding will resume once Air Force 1 departs. Seat Type ID Arrival Time ========================================================================================= First Class 1 1 First Class 4 23 Business Class 2 4 Business Class 3 5 Business Class 7 12 Premium Economy 8 9 Premium Economy 10 26 Premium Economy 15 31 Premium Economy 11 32 Economy 5 13 Economy 6 17 Economy 9 19 Economy 12 22 Economy 13 23 Economy 14 29 Departing - Departures will resume once Air Force 1 departs. Final Departures Nothing to note… ………………………………….TIME SKIP…………………………………. \\ An example of Air Force 1 departing from RFK Minute 56 Events: - Air Force 1 Flight to DCA is now preparing for departure with 12 passengers! Currently Boarding: - Boarding will resume once Air Force 1 departs. Departing - Air Force 1 flight to DCA has 12 passengers and 5 minutes before departure. - Departures will resume once Air Force 1 departs. Final Departures Nothing to note… ………………………………….TIME SKIP…………………………………. \\ An example of Air Force 1 departing from RFK. No events happen until the next minute after final departure. Minute 61 Events: - Air Force 1 has departed! Resuming departures and boarding… Currently Boarding: - Flight to LAX has 11 minutes to board, 8 passenger(s), and 1 person(s) waiting to board. - Flight to MEX has 34 minutes to board, 0 passenger(s), and 0 person(s) waiting to board. Departing - Flight to ONT has 15 passengers and 4 minutes before departure. // Your table should look like tables from your previous assignments. These ID numbers/arrival times may not make sense, but do notice that people in each class are sorted by arrival time. Final Departures RFK -> DCA \\ The end of your program Minute 62 Simulation terminated. Thank you for choosing RFK! Class ID Arrival Time ========================================================================================= First Class 1 1 First Class 4 23 Business Class 2 4 Business Class 3 5 Business Class 7 12 Premium Economy 8 9 Premium Economy 10 26 Premium Economy 15 31 Premium Economy 11 32 Economy 5 13 Economy 6 17 Economy 9 19 Economy 12 22 Economy 13 23 Economy 14 29 Extra Examples \\ An example of a COVID positive person arriving at a boarding queue when a flight is supposed to start departing/finally departing or boarding (they don’t start departing/finally departing). Minute XX Events: - COVID positive passenger found attempting to board flight to LAX! All current departures and boarding extended by 10 minutes! Currently Boarding: \\ Was supposed to start departing, now extra 10 min - Flight to LAX has 10 minutes to board, 8 passenger(s), and 1 person(s) waiting to board. Departing \\ Was supposed to finally depart, given 10 more minutes Flight to SJC has 12 passengers and 10 minutes before departure. Final Departures Nothing to note… \\ An example of a flight trying to start boarding, but, due to the lack of an open terminal (no more space in flightTerminals), is refused Minute XX Events: - Attempting to start boarding for new flight…failed due to lack of open terminal. Currently Boarding: - Flight to LAX has 10 minutes to board, 8 passenger(s), and 1 person(s) waiting to board. Departing Flight to SJC has 12 passengers and 10 minutes before departure. Final Departures Nothing to note… \\ An example of a person attempting to enter a flight’s boarding queue, but, due to the lack of space, is refused Minute XX Events: - New person looking to board flight to LAX…failed due to lack of space in boarding queue. Currently Boarding: - Flight to LAX has 10 minutes to board, 8 passenger(s), and 1 person(s) waiting to board. Departing Flight to SJC has 12 passengers and 10 minutes before departure. Final Departures Nothing to note… \\ An example of an attempt to board a passenger when no one is in the queue. Minute XX Events: - Attempted to board a new passenger…failed due to lack of passengers in boarding queue. Currently Boarding: - Flight to LAX has 10 minutes to board, 8 passenger(s), and 1 person(s) waiting to board. Departing Flight to SJC has 12 passengers and 10 minutes before departure. Final Departures Nothing to note… \\ An example of a person attempting to enter the BoardingQueue after a recently full flight Minute XX Events: - Economy passenger (ID 15) on flight to ONT has boarded on an Economy seat! - Flight to ONT has 15 passengers and is now preparing for departure! - Passenger is attempting to enter boarding queue…failed due to a recently full plane! Currently Boarding: - Flight to LAX has 10 minutes to board, 8 passenger(s), and 1 person(s) waiting to board. Departing Flight to SJC has 12 passengers and 10 minutes before departure. Final Departures Nothing to note… If you find any cases that are not listed in these examples that you think are important, post on Piazza for clarification! Resources: • Here is a stack overflow post detailing how to compute a boolean value given some probability P • https://stackoverflow.com/questions/17359834/random-boolean-with-weight-or-bias • For your mutually exclusive sub-events, you should be able to do something similar to this, mapping certain ranges of a produced float to different events. • Here is an example on how to set a seed for this assignment • https://www.geeksforgeeks.org/random-setseed-method-in-java-with-examples/

pur-new-sol

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE