Question: You have already created and tested a queue class for strings ( zyLabs Queues 1 , 2 , & 3 ) . Now you have
You have already created and tested a queue class for strings zyLabs Queues & Now you have to convert the queuestr class into a template class, so it would work with any data type. To demonstrate the QueueADT class, create two queues:
the first queue contains the names of the students enrolled in CIS C
the second queue contains the number of units each student is taking this quarter
Write code in main to test these functions. Write a loop to enter an unknown number of names, one per line. The loop stops when you enter # As you are entering names, they are to be inserted into the first queue. To test the getLength function display the number of values in both queues, then write another loop to enter the number of units double into a parallel queue. Display the two queues in parallel. On the next line display the front and rear elements in the first queue. On the last line display the front and the rear elements in the second queue.
Example : If the user enters the following names for the first queue:
Ross, Ann
Nour Niya,Tim
Silva, Jamie Lou
Tran, Bob
#
the output is:
At this moment there are strings in the first queue and numbers in the second queue.
Assume the user enters for the second queue. The output is:
Ross, Ann
Nour Niya,Tim
Silva, Jamie Lou
Tran, Bob
Front of the queues: Ross, Ann
Rear of the queues: Tran, Bob
Example : If the user enters # the output is:
Empty Queues!
main.cpp#include
#include
#include "QueueADT.h
using namespace std;
int main
Create the first queue strings
Write a loop to enter an unknown number of names, one per line.
The loop stops when you enter #
As you are entering names, they are to be inserted into the first queue.
Test the getLength function: display the number of elements in the first queue
Create the second queue doubles
Test the getLength function: display the number of elements in the second queue
it should be
Write another loop to enter the number of units double into a parallel queue.
Display the two queues in parallel.
On the next line display the front and rear elements in the first queue.
On the last line display the front and the rear elements in the second queue.
return ;
Queu.ADT.h #ifndef QUEUEADTH
#define QUEUEADTH
template
class Queue
private:
Structure for the stack nodes
struct QueueNode
T value; Value in the node
QueueNode next; Pointer to next node
;
QueueNode front; Pointer to the first node
QueueNode rear; Pointer to the last node
int length; Number of nodes in the queue
public:
Queue front rear NULL; length ; Constructor
~Queue; Destructor
Queue operations
Write your code here
isEmpty
push
pop
peek
peekRear
getLength
;
Member function push: inserts the argument into the queue
Write your code here
Member function deletes the value at the front
of the queue and returns it
Assume queue has at least one node
Write your code here
Destructor
Write your code here
#endif
Input
Ross, Ann
Nour Niya,Tim
Silva, Jamie Lou
Tran, Bob
#
Expected output
Ross, Ann
Nour Niya,Tim
Silva, Jamie Lou
Tran, Bob
Front of the queues: Ross, Ann
Rear of the queues: Tran, Bob
Input
Nour Niya,Tim
Lee, Steve
#
Expected output
Nour Niya,Tim
Lee, Steve
Front of the queues: Nour Niya,Tim
Rear of the queues: Lee, Steve
Input
Gates, Tom
#
Expected output
Gates, Tom
Front of the queues: Gates, Tom
Rear of the queues: Gates, Tom
Input
#
Expected output
Empty Queues!
PLEASE READ THE EVERYTHING,THANK YOU FOR YOUR HELP!!
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
