This is for c++.
Ok, I have most of this done but can't quite figure out how to get the queue to appear on screen. I also think I may have messed up my loops as well. What it is supposed to do is ask what the user wants to do and then it will carry that step out and then ask the user what to do again etc... until the user decides to quit. I was hoping you guys could help me with fixing my loops and getting the queue to appear on screen like it should.
//.H FILE
#include <iostream>
#define SIZE 30
using namespace std;
class queue
{
int a[SIZE];
int front;
int rear;
public:
queue();
~queue();
void insert(int i);
int remove();
int isEmpty();
int isFull();
int print();
};
queue::queue()
{
front = 0;
rear = 0;
}
queue::~queue()
{
delete []a;
}
void queue::insert(int i)
{
if(isFull())
{
cout << "Queue is full.";
return;
}
a[rear] = i;
rear++;
}
int queue::remove()
{
if(isEmpty())
{
cout << "Queue is empty.";
return (-9999);
}
return(a[front++]);
}
int queue::isEmpty()
{
if(front == rear)
return 1;
else
return 0;
}
int queue::isFull()
{
if(rear == SIZE)
return 1;
else
return 0;
}
void print()
{
//code for appearing on screen goes here I think
}
//C++ FILE
#include <iostream>
#include <iomanip>
#include "Lab 8.h"
using namespace std;
int main()
{
queue list;
int choice;
int value;
cout << "1. Insert and dispaly" << endl;
cout << "2. Delete and display" << endl;
cout << "3. Exit" << endl;
cout << "Enter your choice: ";
cin >> choice;
do
{
if ( choice == 1 )
{
cout << "Enter your value to be inserted: ";
cin >> value;
cout << //Queue with added item will go here
}
else if(choice == 2)
{
cout << //Queue with deleted item will go here
}
}
while ( choice != 3);
{
}
if ( choice == 3)
{
cout << "Done." << endl;
system ("PAUSE");
return 0;
}
system ("PAUSE");
return 0;
}
Hopefully I explained it enough so you guys can understand it. If more info is needed please just ask and I will provide it. Thank you for any help.