Question: Variable paychecksQueue is a Queue of type Integer. Integers are read from input and are added to paychecksQueue until - 9 9 is read. While
Variable paychecksQueue is a Queue of type Integer. Integers are read from input and are added to paychecksQueue until is read. While paychecksQueue is not empty, repeat the following:
Remove the element at the head of paychecksQueue.
If the element's value is greater than or equal to then output "Paycheck delivered. Unpaid hours returned to queue: followed by the element minus and insert the remainder to the tail of paychecksQueue.
Otherwise, output the element followed by hours: paycheck not delivered yet".
End each output with a newline.
Ex: If the input is then the output is:
Paycheck delivered. Unpaid hours returned to queue:
hours: paycheck not delivered yet
hours: paycheck not delivered yet
Queue is empty
import java.util.Queue;
import java.util.Scanner;
import java.util.LinkedList;
public class NumberOfPaychecksQueue
public static void mainString args
Scanner scnr new ScannerSystemin;
Queue paychecksQueue new LinkedList;
int paycheckValue;
paycheckValue scnrnextInt;
while paycheckValue
paychecksQueue.addpaycheckValue;
paycheckValue scnrnextInt;
while paychecksQueuepeek null
Your code goes here
int currentPaycheck paychecksQueue.poll;
if currentPaycheck && currentPaycheck
System.out.printlnQueue is empty";
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
