Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

c++ #include #include using namespace std; #define MAX_SIZE 50 // Define maximum

ID: 3700399 • Letter: C

Question

c++

#include
#include
using namespace std;

#define MAX_SIZE    50        // Define maximum length of the queue

class Queue
{
    private:
        int head, tail;           // Index to top of the queue
        int theQueue[MAX_SIZE]; // The queue

    public:
        Queue();         // Class constructor
        bool Enqueue(int num);   // Enter an item in the queue
        int Dequeue();          // Remove an item from the queue
        bool isEmpty();          // Return true if queue is empty
        bool isFull();           // Return true if queue is full
        void displayQueue();
};
Queue::Queue()
{
   head = tail = -1;
}
bool Queue::Enqueue(int num)
{
   // Check to see if the Queue is full
   if(isFull()) return false;

   // Increment tail index
   tail++;
   // Add the item to the Queue
   theQueue[tail % MAX_SIZE] = num;
   return true;
}
int Queue::Dequeue()
{
   int num;

   // Check for empty Queue
   if(isEmpty()) return ''; // Return null character if queue is empty
   else
   {
       head++;
       num = theQueue[head % MAX_SIZE];       // Get character to return
       return num;               // Return popped character
   }
}

bool Queue::isEmpty()
{
   return (head == tail);
}
bool Queue::isFull()
{
   // Queue is full if tail has wrapped around
   //   to location of the head. See note in
   //   Enqueue() function.
   return ((tail - MAX_SIZE) == head);
}

void Queue::displayQueue(){
   for (int i = head+1; i <= tail; i++) {
       cout << theQueue[i] << " ... ";
   }
   cout << endl << endl;
}

? Sudents NSU Labs Sering 2218 Comp P,L X ttpalhau .blocdoandoor.obcsweocayp d 2173908 dt content nd ?1891519_1/cours CSC 260L PARLN 1.01.0J 172.2 IIE Given a goen nmQumnn; (50 points) a. Enqu200 randoly generated integers (ranging 0-120, inclusively) inohmQueue b. Search the:lum,guewe lor lhe element Lhal has value ?? ?ngrealer ànd 'elurn Ihe Loun1 01 >-G0" in the num@cu c. Print out all other numbers (except"-60) in the original order. Save your file as labo9Less Ihan60 finitiollastNome.cpp 3. Given a 5tack S: (Ronus 20 points)-nly get honus if you finish the first 2 programs Write code to reverse all the elements in S. Algorithm: Create a temporary queue; transfer all of the stack's elements into the queue Note: The algorithm for this question is very similar to the example given above Save your file as laboSReverseStack finitialLostName.cpp queue transfer all of the queue's items back into the stack

Explanation / Answer

Below are the required files. I have created 3 files for each exercise. Also I have created Stack.h and Stack.cpp as these classes are not given. I have seperated Queue.cpp into Queue.h and Queue.cpp, so Queue.cpp now will only have method definitions. Run all three main files and verify the Outputs. Let me know if any questions.

Queue.h

Queue.cpp

Stack.h

Stack.cpp

lab09LessThan60.cpp

lab09ModifyQueue.cpp

lab09ReverseStack.cpp

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote