Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help filling in the areas, unsure of how to do the code, JAVA. I've highlited what needs completing. import java.util.Queue ; import java.util.LinkedList ;

Need help filling in the areas, unsure of how to do the code, JAVA. I've highlited what needs completing. 

import java.util.Queue ; import java.util.LinkedList ; /** Practices using the Queue from the Java API. */ public class QueueApiTester { public static void main(String[] args) { Queue queue = new LinkedList() ; queue.add("horse") ; queue.add("cat") ; queue.add("dog") ; queue.add("cow") ; queue.add("mouse") ; System.out.println(queue.remove()) ; System.out.println(queue.remove()) ; System.out.println(queue.remove()) ; System.out.println(queue.peek()) ; System.out.println("queue is empty? " + queue.isEmpty()) ; System.out.println(queue.remove()) ; System.out.println("queue is empty? " + queue.isEmpty()) ; System.out.println(queue.remove()) ; System.out.println("queue is empty? " + queue.isEmpty()) ; //-----------Start below here. To do: approximate lines of code = 7 // 1. make a queue q2 that holds integers ; //2. put in the integers from 1 to 100 that are divisible by 3 ; //3. print the size of the queue //4. while not empty ; //5. remove an integer and put it in value ; //6-7. print the value if divisible by 9. //-----------------End here. Please do not remove this comment. Reminder: no changes outside the todo regions. } } 

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

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions