Question: Variable airportsQueue is a Queue of type String. Strings are read from input and are added to airportsQueue until done is read. Then, integer numRounds
Variable airportsQueue is a Queue of type String. Strings are read from input and are added to airportsQueue until "done" is read. Then, integer numRounds is read. If airportsQueue is not empty, repeat the following numRounds times:
Remove the element at the head of airportsQueue.
Output the element followed by cleared and rejoins queue".
Add the element back to airportsQueue.
End each output with a newline.
Ex: If the input is Dublin Guangzhou done then the output is:
Dublin cleared and rejoins queue
Guangzhou cleared and rejoins queue
Dublin cleared and rejoins queue
Guangzhou cleared and rejoins queue
Dublin cleared and rejoins queue
Note: Input may only contain "done".
import java.util.Queue;
import java.util.Scanner;
import java.util.LinkedList;
public class AirpotFlightStatus
public static void mainString args
Scanner scnr new ScannerSystemin;
Queue airportsQueue new LinkedList;
String airportValue;
int numRounds;
int i;
airportValue scnrnext;
while airportValue.equalsdone
airportsQueue.addairportValue;
airportValue scnrnext;
numRounds scnrnextInt;
Your code goes here
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
