Queue question , please solve as requested , thank you
this is the unbounded queue interface
QUESTION 1: (QUEUE ADT) [5 POINT Write a Java program that repeatedly prompts the user to enter strings, using the string "E end" to indic when finished. The user is assumed to only enter strings of the form " F fruitname" or "D drinknam Output the names that had "D" indicated in the same order they were entered, preceded by the str "Drink: " and then do the same for the names that had " F " indicated, preceded by the string "Fruit anything else keep them in the original queue and output them, preceded by the string "Not Classified : Use ArrayUnboundedQueue objects in your program. ArrayUnboundedQueue code . public class ArrayUnboundedQueue
implements UnboundedQueueInterface \{ protected final int DEFCAP =100;// default capacity protected T] elements; // array that holds queue elements protected int origCapinn // original capacity protected int numElements =0;// number of elements n the queue protected int front =0 im // index of front of queue protected int rear : // index of rear of queue public ArrayUnboundedQueue 0 \{ elements =( TI] ) new Object[DEFCAP]; rear = DEFCAP 1; origCap = DEFCAP; 3 public ArrayUnboundedQueue(int origCap) \{ elements = (TII) new Object[origCap]; rear = origCap 1 this.origCap = origCap public void enqueue(T element) // Adds element to the rear of this queue. \{ if (numElements = elements.length) enlarge0; rear =( rear +1)% elements.length: elements [rear] = element; numElements = numElements +1; \} (a) Override public T dequeue Throws QueueUnderflowException if this queue is empty, / otherwise removes front element from this queue and returns it. \{ if (isEmptyO) throw new QueueUnderflowException("Dequeue on empty queue."); else \{ T toReturn = elements [front]; elements [front] = null; front =( front +1)% elements.length; numElements = numElements - 1; return toReturn; 3 3 @ Override public boolean isEmptr0 / Returns true if this queue is empty, otherwise returns false \{ return (numElements ==0 ); 3 // NO isFullo method private void enlarge0 // Increments the capacity of the queue by an amount // equal to the original capacity. \{ // create the larger array T]] larger =(T[]) new Object[elements.length + origCap]; // copy the contents from the smaller array into the larger array int currSmaller = front; for (int currLarger =0; currL arger