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 1,2, & 3). Now you have to convert the queue_str 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 22C
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 1: If the user enters the following names for the first queue:
Ross, Ann
Nour Niya,Tim
Silva, Jamie Lou
Tran, Bob
#
the output is:
40
At this moment there are 4 strings in the first queue and 0 numbers in the second queue.
Assume the user enters 94.51513.5 for the second queue. The output is:
Ross, Ann 9
Nour Niya,Tim 4.5
Silva, Jamie Lou 15
Tran, Bob 13.5
Front of the queues: Ross, Ann 9
Rear of the queues: Tran, Bob 13.5
Example 2: 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 0!)
// 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 0;
}
Queu.ADT.h// #ifndef QUEUE_ADT_H
#define QUEUE_ADT_H
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 =0; }//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
#
13.5184.59
Expected output
40
Ross, Ann 13.5
Nour Niya,Tim 18
Silva, Jamie Lou 4.5
Tran, Bob 9
Front of the queues: Ross, Ann 13.5
Rear of the queues: Tran, Bob 9
Input
Nour Niya,Tim
Lee, Steve
#
9
4.5
Expected output
20
Nour Niya,Tim 9
Lee, Steve 4.5
Front of the queues: Nour Niya,Tim 9
Rear of the queues: Lee, Steve 4.5
Input
Gates, Tom
#
21
Expected output
10
Gates, Tom 21
Front of the queues: Gates, Tom 21
Rear of the queues: Gates, Tom 21
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 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 Finance Questions!