PR19-10.cpp --------------------------------------------------------------------
ID: 3739171 • Letter: P
Question
PR19-10.cpp
----------------------------------------------------------------------------------------
// This program demonstrates the DynamicQueue template.
#include <iostream>
#include <string>
#include "DynamicQueue.h"
using namespace std;
const int QUEUE_SIZE = 5;
int main()
{
string name;
// Create a Queue.
DynamicQueue<string> queue;
// Enqueue some names.
for (int count = 0; count < QUEUE_SIZE; count++)
{
cout << "Enter a name: ";
getline(cin, name);
queue.enqueue(name);
}
// Dequeue the names and display them.
cout << " Here are the names you entered: ";
for (int count = 0; count < QUEUE_SIZE; count++)
{
queue.dequeue(name);
cout << name << endl;
}
system("pause");
return 0;
}
--------------------------------------------------------
Modify? Pr19-10.cpp :
a. Create an integer queue
b. Put following integers into the queue: 5, 10, 15, 20, and 25
c. Remove and display the integers from the queue.
Explanation / Answer
// This program demonstrates the DynamicQueue template.
#include <iostream>
#include <string>
#include "DynamicQueue.h"
using namespace std;
const int QUEUE_SIZE = 5;
int main()
{
int n;
// Create a Queue.
DynamicQueue<int> queue;
queue.enqueue(5);
queue.enqueue(10);
queue.enqueue(15);
queue.enqueue(20);
queue.enqueue(25);
// Dequeue the names and display them.
cout << " Here are the integere in the queue: ";
for (int count = 0; count < QUEUE_SIZE; count++)
{
queue.dequeue(n);
cout << n << endl;
}
system("pause");
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.