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 -99 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 120, then output "Paycheck delivered. Unpaid hour(s) returned to queue: " followed by the element minus 120, and insert the remainder to the tail of paychecksQueue.
* Otherwise, output the element followed by " hour(s): paycheck not delivered yet".
End each output with a newline.
Ex: If the input is 14154-99, then the output is:
Paycheck delivered. Unpaid hour(s) returned to queue: 21
54 hour(s): paycheck not delivered yet
21 hour(s): 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 main(String[] args){
Scanner scnr = new Scanner(System.in);
Queue paychecksQueue = new LinkedList();
int paycheckValue;
paycheckValue = scnr.nextInt();
while (paycheckValue !=-99){
paychecksQueue.add(paycheckValue);
paycheckValue = scnr.nextInt();
}
while (paychecksQueue.peek()!= null){
/* Your code goes here */
int currentPaycheck = paychecksQueue.poll();
if (currentPaycheck >=500 && currentPaycheck <=1000){
}
System.out.println("Queue is empty");
}
}

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!