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 5, 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 main(String[] args){
Scanner scnr = new Scanner(System.in);
Queue airportsQueue = new LinkedList();
String airportValue;
int numRounds;
int i;
airportValue = scnr.next();
while (!airportValue.equals("done")){
airportsQueue.add(airportValue);
airportValue = scnr.next();
}
numRounds = scnr.nextInt();
/* Your code goes here */
}
}

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 Programming Questions!