EE221 Assignment 9
Program 1 (30pts.)
Complete the provided fixed size array-based rotary Queue class by
altering and or adding the following functionality:
- Alter the behavior of the enqueue(.) - in case of adding an element to a full queue make room by forgetting the oldest (front) element so that the new element can be added.
- Implement dequeueAll() - quickly purge the queue data by resetting myFront and myBack.
- Implement boolean ready() - return true if at least QUEUE_SHORT elements are stored in the queue. Note that the queue may roll over myArray[0], i.e. myFront<myBack so it is not simply (myBack-myFront>=5)
- Implement ShortAverage() - compute the average of the most recent QUEUE_SHORT elements
- Implement LongAverage() - compute the average of all stored elements, note that the queue might not always be full at that time.
- If you have enough skills to do so: consider computing averages should be done efficiently if possible, i.e. hold a sum of all appropriate elements in a variable and update the sum by adding the newest element and removing the oldest element.
Use the following start up queue library and the provided implementation
program. Do not modify the implementation program. Doing correct testing
of your queue by feeding enough data so that all features are tested
will also be evaluated.
Why the program beeps if short average is greter than four?