Question: Variable colorsQueue is a Queue of type String. Strings are read from input and are added to colorsQueue until done is read. Then, integer numRounds

Variable colorsQueue is a Queue of type String. Strings are read from input and are added to colorsQueue until "done" is read. Then, integer numRounds is read. If colorsQueue is not empty, repeat the following numRounds times:
Remove the element at the head of colorsQueue.
Output the element followed by " processed and rejoins queue".
Add the element back to colorsQueue.
End each output with a newline.
Ex: If the input is brown done 4, then the output is:
brown processed and rejoins queue
brown processed and rejoins queue
brown processed and rejoins queue
brown processed and rejoins queue
Note: Input may only contain "done".

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