Question: 01. implement a class function in the cqueue class to print all the elements from thequeue (without dequeueing them!) [10 points] 02. implement a class

01. implement a class function in the cqueue class to print all the elements from thequeue (without dequeueing them!) [10 points] 02. implement a class function in the cqueue class to count the current size of the queue(if you have inserted 5 elements and dequeued 3, the current size is 2, initially the queue size is 0) [10 points] 03. implement a class function for dequeue class to dequeue all the elements from the queue (print each element as you delete them) [10 points]

04. modify the while loop in the main function to take the input from user while enqueuing new value. [05 Points]

Add 3 test cases for each completed task with your submitted code.

Bonus:

Pick any 2 out of Task 01, 02, and 03. Each carries 10 points. If you can complete all three (01, 02, 03), the third one will be bonus point and will be added to any of the previous recitation quiz of your choice (mention which one to pick!).

#include "cqueue.h" #include  using namespace std; cqueue :: cqueue() { front = rear = -1; } void cqueue :: enqueue(int x) { if ((rear+1) % 10 == front) { cout << "The queue is full"<< endl; return; } else { rear = (rear + 1) % 10; q[rear] = x; if (front == -1) front = 0; } } int cqueue :: dequeue () { if ((front == rear) && (rear == -1)) { cout << "The queue is empty!"<< endl; return -1; } else { int x = q[front]; if(front == rear) { front = rear = -1;} else front = (front + 1) % 10; return x; } } 
#ifndef cqueue_H #define cqueue_H class cqueue { int q[10]; int front; int rear; public: cqueue(); void enqueue(int); int dequeue(); }; #endif 
#include #include "cqueue.h" using namespace std; int main() { cqueue q; char c = 'c'; //enter 's' to end int j = 20; while(c != 's') { cout << "enter 'e' to enqueue "<< endl << "enter 'd' to dequeue" << endl << "enter 's' to stop"<< endl; cin >> c; if (c == 'e') q.enqueue(j++); else if (c == 'd'){ int v = q.dequeue(); cout << "Current Value: "<< v << endl; } else break; } return 0; } 

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!