Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

please if your code don\'t work, please don\'t answer the question . I was strug

ID: 3810082 • Letter: P

Question

please if your code don't work, please don't answer the question . I was struggling with the question, with time i would be able to answer the question but i've got limited time. This Program is in C++.

Problem Statement
Customers of the Muscat Group are required to come in once a month to handle personal business. Each customer gets 10 minutes with a consultant in order to complete their business. At the end of the 10 minutes the consultant ends the conversation with the current customer and invites a new customer who has been waiting to come. At this point the previous customer can say they have finished their business or they can determine if they must get back into the wait state. In order to ensure each customer is seen, each customer who repeatedly gets in line does so with a lower priority. That is, first time seen customers have a higher priority then the second attempt customers. The second attempt customers have a higher priority than the third attempt customers and so on.

Write a program that simulates this environment and asks the customers if they have finished or require more time with a consultant.
NOTE: It is important to remember that you have to choose the appropriate data structures and members to represent a customer.

Explanation / Answer

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
using namespace std;

/*
* CustomerQueue Declaration
*/
struct CustomerQueue
{
   int priority;
   int customerCode;
   struct CustomerQueue *link;
};
/*
* Class Priority Queue
*/
class PriorityQueue
{
private:
CustomerQueue *head;
public:
PriorityQueue()
{
head = NULL;
}
/*
* Insert into Priority Queue
*/
void insert(int customerInfo, int priority)
{
CustomerQueue *tmp, *q;
tmp = new CustomerQueue;
tmp->customerCode = customerInfo;
tmp->priority = priority;
if (head == NULL || priority < head->priority)
{
tmp->link = head;
head = tmp;
}
else
{
q = head;
while (q->link != NULL && q->link->priority <= priority)
q=q->link;
tmp->link = q->link;
q->link = tmp;
}
}
/*
* Delete from Priority Queue
*/
void del()
{
CustomerQueue *tmp;
if(head == NULL)
cout<<"Queue Underflow ";
else
{
tmp = head;
cout<<"Deleted customerInfo is: "<<tmp->customerCode<<endl;
head = head->link;
free(tmp);
}
}
  
/*
* Print Priority Queue
*/
void display()
{
CustomerQueue *ptr;
ptr = head;
if (head == NULL)
cout<<"Queue is empty ";
else
{   cout<<"Queue is : ";
cout<<"Priority customerInfo ";
while(ptr != NULL)
{
cout<<ptr->priority<<" "<<ptr->customerCode<<endl;
ptr = ptr->link;
}
}
}

       int getLeastPrirotiy(){
       CustomerQueue *Localptr;
       Localptr = head;
           while(Localptr != NULL)
           {
               cout<<Localptr->priority<<" "<<Localptr->customerCode<<endl;
               Localptr = Localptr->link;
           }
           int lowestPriority = Localptr->priority;
       }
          
};
/*
* Main
*/
int main()
{
int choice;
   int customerInfo, priority;
   int leastPriority;
   int isBusinessDone = 1;
PriorityQueue pq;
do
{
cout<<"1. Insert Customer who all will get participated in bussiness meeting ";
cout<<"2. Schedule consultant and customer meeting ";
cout<<"3. Display the Customer waiting list ";
cout<<"4. Quit ";
cout<<"Enter your choice : ";
cin>>choice;
switch(choice)
{
case 1:
cout<<"Input the customer Code ( Integer like 101,102 etc) to be added in the list : ";
cin>>customerInfo;
cout<<"Enter its priority : ( Integer value, It can be anything ) ";
cin>>priority;
pq.insert(customerInfo, priority);
break;
case 2:
cout << "New Customer Invited for meeting " << endl;
           //sleep(5000);
               if(isBusinessDone == 1){  
                   pq.del();
                   cout <<" Customer has finished thier business : " <<endl;
               }else{
                   pq.del();
                   cout <<" : Customer has not finished thier business and go for wait stat with lower priority : " <<endl;
                   int lowestPriority = pq.getLeastPrirotiy();
                   cout << "least priority" << lowestPriority << endl;
                   pq.insert(customerInfo, lowestPriority);      
               }
break;
case 3:
pq.display();
break;
case 4:
           //pq.isEmpty();
break;
       case 5:
default :
cout<<"Wrong choice ";
}
}
while(choice != 5);
return 0;
}

Description :

To see the program poutput, just copy the test in good editor like edit plus, notepad++ so that you can make better understanding on same.

let me know you face any chalanges to run the above program.

Steps to Run

---------------------

Chosse option 1 : To insert all the customer details ( ciustomer code and their priority)

choose option 2 : to schedule metting with consultant with customer.

choose option 3 : To check the customer queue at any point of time according to their priority.

choose option 4 ; quit from program.

Output

------------

1. Insert Customer who all will get participated in bussiness meeting 2. Schedule consultant and customer meeting 3. Display the Customer waiting list 4. Quit Enter your choice : 1 Input the customer Code ( Integer like 101,102 etc) to be added in the list : 101 Enter its priority : ( Integer value, It can be anything ) 2 1. Insert Customer who all will get participated in bussiness meeting 2. Schedule consultant and customer meeting 3. Display the Customer waiting list 4. Quit Enter your choice : 1 Input the customer Code ( Integer like 101,102 etc) to be added in the list : 201 Enter its priority : ( Integer value, It can be anything ) 3 1. Insert Customer who all will get participated in bussiness meeting 2. Schedule consultant and customer meeting 3. Display the Customer waiting list 4. Quit Enter your choice : 3 Queue is : Priority customerInfo 2 101 3 201 1. Insert Customer who all will get participated in bussiness meeting 2. Schedule consultant and customer meeting 3. Display the Customer waiting list 4. Quit Enter your choice : 2 New Customer Invited for meeting Deleted customerInfo is: 101 Customer has finished thier business : 1. Insert Customer who all will get participated in bussiness meeting 2. Schedule consultant and customer meeting 3. Display the Customer waiting list 4. Quit Enter your choice : 3 Queue is : Priority customerInfo 3 201 1. Insert Customer who all will get participated in bussiness meeting 2. Schedule consultant and customer meeting 3. Display the Customer waiting list 4. Quit Enter your choice : 4 1. Insert Customer who all will get participated in bussiness meeting 2. Schedule consultant and customer meeting 3. Display the Customer waiting list 4. Quit Enter your choice :

Program terminated (signal: SIGKILL)