Question: Write a Java source code named Queue.java to implement the following functions of a Queue using an integer array: queue_init(): Make the queue empty empty();

Write a Java source code named "Queue.java" to implement the following functions of a Queue using an integer array: queue_init(): Make the queue empty empty(); return true if the queue is empty. Return otherwise enqueue(val): add the item val to the queue dequeue(): remove the item least recently added to the queue front(): return the item least recently added to the queue, but do not remove it. the program reads in integer values as input: for a positive integer input value greater than 0, the program will insert the value into the queue, i.e. enqueue for any negative integer input value, the program will return the least recently added value from the queue if it is non-empty, i.e. front for the input value 0, the program will remove the least recently added value from the queue if it is non-empty, i.e. dequeue test your program with the following set of input: Expected Output "Error - Queueis empty" 78 456 60 33 -1 O "Error - Queueis empty" "Error - Queueis empty
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
