Question: Question 4) [8 Points] Write a method called BelowAvg to be included in class QueueEx. The method has one parameter q1 of type Arrayqueue of
Question 4) [8 Points] Write a method called BelowAvg to be included in class QueueEx. The method has one parameter q1 of type Arrayqueue of integers. The method finds the average of elements in q1, and moves every element in q1 less than the average to another queue that will be returned at the end of the method ( q1 will then be containing only the elements greater than the average). Assume that the queue is not empty and the class ArrayQueue is available for use. Use common queve operations only such as offer, poll, peek, IsEmpty and copy constructor. In the method, you must use the Iterator for the part related to finding the average, for the rest of the method it is up to you to use the Iterator or without iterator. [Note: The ArrayQueue class does not have size attribute (number of elements in the queue)]. The method head is public static ArrayQueue belownvg (ArrayoueuecInteger> qI) Example: \begin{tabular}{l} After method call: (Average is 9.5) \\ q2: 121015 \\ front rear \\ Returned Queues 479 \\ \multicolumn{4}{|c|}{ front rear } \\ \hline \end{tabular} public static ArrayQueuecInteger> belownvg(ArrayoueuecInteger q1)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
