Question: Using java, fill in the enqueue and dequeue functions so that the following program will give the desired output. *Download the java source file. *You

Using java, fill in the enqueue and dequeue functions so that the following program will give the desired output. *Download the java source file. *You will fill in (write) the "enqueue" and "dequeue" functions. *Leave the rest of the code in the file alone; don't change anything except "enqueue" and "dequeue." *Your code must successfully compile using javac at the command line. You can use whatever IDE you choose (netbeans, eclipse, nano, etc...) just as long as your code still passes the javac compiler (which it should if you use a standard compliant IDE). 

import java.util.LinkedList; public class IntegerQueue { private LinkedList fooList; public IntegerQueue() { // The Constructor. Initializes our linked list to use as a queue. fooList = new LinkedList(); } public int dequeue() { // todo - write this function. } public void enqueue( int newElement ) { // todo - write this function. } public static void main( String[] args ) { // main entry point of program. System.out.println( "Main Driver: Testing the queue. "); IntegerQueue myQueue = new IntegerQueue(); // Allocate a queue using a linked list. myQueue.enqueue( 10 ); myQueue.enqueue( 20 ); myQueue.enqueue( 30 ); myQueue.enqueue( 40 ); myQueue.dequeue(); myQueue.dequeue(); myQueue.enqueue( 50 ); myQueue.enqueue( 60 ); myQueue.dequeue(); System.out.println( "The queue should now contain: 40 50 60 "); System.out.println( "The queue contains: "); System.out.println( myQueue.dequeue() ); System.out.println( myQueue.dequeue() ); System.out.println( myQueue.dequeue() ); } } // end of IntegerQueue 

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!