Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Mining Concepts And Techniques

Authors: Jiawei Han, Micheline Kamber, Jian Pei

3rd Edition

0123814790, 9780123814791

More Books

Students also viewed these Databases questions

Question

Explain three ways that sales employees are typically compensated.

Answered: 1 week ago

Question

What is the most important part of any HCM Project Map and why?

Answered: 1 week ago