Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C + + Creating StudentRoster Queue Download and Unzip: o Download Queue.zip and unzip the contents. o Take a moment to understand the functioning of

C++ Creating StudentRoster Queue
Download and Unzip:
o Download "Queue.zip" and unzip the contents.
o Take a moment to understand the functioning of the queue.
Implement the StudentRosterQueue.h header file and the driver.cpp program.
Exception Handling:
o Create both EmptyQueue and FullQueue classes to handle exceptions.
Testing in driver.cpp:
o Read an input file and add all records to the queue.
o Print all elements in the queue.
o Dequeue multiple times until the EmptyQueue exception occurs.
o Implement a try-catch statement for handling the exception.
o Whenever a dequeue occurs, print all elements in the current queue.
Students.txt :
Betsy 123456789 A
Sam Spade 234565677 B
Annie Smith 324233456 A
Thomas J. Jones 345344344 A
Allan Adaire 324234234 C
Jennifer Smallville 234234333 A
//Queue.h
#pragma once
#include
using namespace std;
struct NodeType {
char value;
NodeType* next;
};
class Queue {
private:
NodeType* qFront;
NodeType* qRear;
public:
Queue();
//~Queue();
bool isEmpty();
bool isFull();
void enqueue(char);
void dequeue(char& x);
void displayQueue();
};
Queue::Queue()
{
qFront = qRear = NULL;
}
void Queue::displayQueue()
{
NodeType* nodePtr = qFront;
while (nodePtr != NULL)
{
cout << nodePtr->value <<"";
nodePtr = nodePtr->next;
}
}
bool Queue::isEmpty()
{
if (qFront == NULL)
return true;
else
return false;
}
bool Queue::isFull()
{
NodeType* ptr = new NodeType;
if (ptr == NULL)
return true;
else {
delete ptr;
return false;
}
}
void Queue::enqueue(char x)
{
if (isFull()) exit(1);
NodeType* newNode = new NodeType;
newNode->value = x;
newNode->next = NULL;
if (qFront == NULL)
qFront = newNode;
else
qRear->next = newNode;
qRear = newNode;
}
void Queue::dequeue(char &x)
{
if (isEmpty())
exit(1);
x = qFront->value;
NodeType* temp = qFront;
qFront = qFront->next;
delete temp;
}
//QueueTest.cpp
#include
#include "Queue.h"
using namespace std;
int main()
{
Queue q;
char ch;
q.enqueue('a');
q.enqueue('c');
q.enqueue('p');
q.enqueue('d');
q.dequeue(ch);
cout <<"ch: "<< ch << endl;
q.displayQueue();
return 0;
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Upgrading Oracle Databases Oracle Database New Features

Authors: Charles Kim, Gary Gordhamer, Sean Scott

1st Edition

B0BL12WFP6, 979-8359657501

More Books

Students also viewed these Databases questions

Question

How do Dimensional Database Models differ from Relational Models?

Answered: 1 week ago

Question

What type of processing do Relational Databases support?

Answered: 1 week ago

Question

Describe several aggregation operators.

Answered: 1 week ago