Please answer in C++ and include a sample output Create a class named waitList t
ID: 666787 • Letter: P
Question
Please answer in C++ and include a sample output
Create a class named waitList that can store a name and number of guests. Use constructors to automatically initialize the member variables.
Add the following operations to your program:
1)Return the first person in the queue
2)Return the last person in the queue
3)Add a person to the queue
4)Delete a person from the queue
Create a main program to test your class. Your main program should contain the following options. Create a menu for your options.
1)Add a guest (adds the reservation name and number of guests)
2)Delete a guest (the user must give you the name to delete, the list may be empty or the guest may not be in the list)
3)Show last guest waiting (return NONE if the queue is empty)
4)Show first guest waiting (return NONE if the queue is empty)
5)Exit
Thank you!!
Explanation / Answer
#include <stdio.h>
#include <stdlib.h>
#define MAX 5
void insertint);
void delete(int);
void create();
void check(int);
void display_pqueue();
int pri_que[MAX];
int front, rear;
void main()
{
int n, ch;
printf(" 1 - Insert an element into queue");
printf(" 2 - Delete an element from queue");
printf(" 3 - Display queue elements");
printf(" 4 - Exit");
create();
while (1)
{
printf(" Enter your choice : ");
scanf("%d", &ch);
switch (ch)
{
case 1:
printf(" Enter value to be inserted : ");
scanf("%d",&n);
insert_by_priority(n);
break;
case 2:
printf(" Enter value to delete : ");
scanf("%d",&n);
delete_by_priority(n);
break;
case 3:
display_pqueue();
break;
case 4:
exit(0);
default:
printf(" Choice is incorrect, Enter a correct choice");
}
}
}