Code in java. This is a large problem but I only need help with part 2. I already have the code from part 1. You may mod

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Code in java. This is a large problem but I only need help with part 2. I already have the code from part 1. You may mod

Post by answerhappygod »

Code in java.
This is a large problem but I only need help with
part 2. I already have the code from part 1. You may
modify the given code if you wish.
Code In Java This Is A Large Problem But I Only Need Help With Part 2 I Already Have The Code From Part 1 You May Mod 1
Code In Java This Is A Large Problem But I Only Need Help With Part 2 I Already Have The Code From Part 1 You May Mod 1 (134.72 KiB) Viewed 65 times
Code In Java This Is A Large Problem But I Only Need Help With Part 2 I Already Have The Code From Part 1 You May Mod 2
Code In Java This Is A Large Problem But I Only Need Help With Part 2 I Already Have The Code From Part 1 You May Mod 2 (39.56 KiB) Viewed 65 times
Code In Java This Is A Large Problem But I Only Need Help With Part 2 I Already Have The Code From Part 1 You May Mod 3
Code In Java This Is A Large Problem But I Only Need Help With Part 2 I Already Have The Code From Part 1 You May Mod 3 (48.11 KiB) Viewed 65 times
Code In Java This Is A Large Problem But I Only Need Help With Part 2 I Already Have The Code From Part 1 You May Mod 4
Code In Java This Is A Large Problem But I Only Need Help With Part 2 I Already Have The Code From Part 1 You May Mod 4 (9 KiB) Viewed 65 times
enum TravelClass {
First_Class,
Bussiness_Class,
Premium_Economy,
Economy;
}
// defining the class Passenger as required with complete
documentation
public class Passenger {
// defining the data members of the Passenger class as
given
private TravelClass passClass;
private int passengerID;
private int arrivalTime;
// default contructor
public Passenger() {
passengerID = 0;
arrivalTime = 0;
passClass = TravelClass.Economy;
}
// parameterized constructor
public Passenger(int passengerID, int arrivalTime, TravelClass passClass)
{
this.passengerID = passengerID;
this.arrivalTime = arrivalTime;
this.passClass = passClass;
}
/**
* setter function for arrival time
*
* @param arrivalTime
*/
public void setArrivalTime(int arrivalTime)
{
this.arrivalTime = arrivalTime;
}
/**
* setter function for passenger id
*
* @param passengerID
*/
public void setPassengerID(int passengerID)
{
this.passengerID = passengerID;
}
/**
* setter function for passClass
*
* @param passClass
*/
public void setPassClass(TravelClass passClass)
{
this.passClass = passClass;
}
/**
* getter function for arrival time
*
* @return int
*/
public int getArrivalTime()
{
return arrivalTime;
}
/**
* getter function for passenger id
*
* @return int
*/
public int getPassengerID()
{
return passengerID;
}
/**
* getter function for passClass
*
* @return TravelClass
*/
public TravelClass getPassClass()
{
return passClass;
}
}
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, a passenger is dequeued from a flight's BoardingQueue and counted against a plane's capacity. (P = Given) 2. For each boarding flight, 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's 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.
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 final int variable o CAPACITY Three int variables: o front o rear o size • public void enqueue Passenger(Passenger newPass) ○ Brief: Enqueues a passenger to the BoardingQueue keeping in mind their class and ID. 。 Parameters: newPass - passenger to be enqueued. o Preconditions None. o Postconditions newPass is enqueued in the BoardingQueue. ○ Returns None. Throws NoRoomException - Thrown when there is no more room in the queue. • public Passenger dequeue Passenger(Passenger nextPass) ○ Brief: Dequeues the next passenger from the BoardingQueue. O Parameters: nextPass - passenger to be dequeued. 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.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply