99 799
Assignments Done
98.4%
Successfully Done
In June 2021

# Answer to Question #47987 in C++ for zinkarocks

Question #47987
Problem statement
ANZ call centre receives hundreds of calls per day and they want an efficient way to
handle all the receiving calls. The clear directive from customer service department is to
give fair chance to each customer on first come first serve basis.

Requirements
To solve the above problem you will need a queue data structure to keep all the receiving
calls. Recall queue uses First In First Out (FIFO) principle. Customer service consultants
can take a caller at a time from the queue and the queue is open for other callers. A caller
must leave a name and message and hang up the phone so that a consultant could attend to
him/her when the caller gets his/her chance from the queue.
It is clear from the given description that you would need to have queue of callers where
for each caller you must store the phone number, name and message attributes. Assume
the capacity of the queue cannot be more than 10.
1
2014-10-28T01:46:21-0400
#include <stdlib.h>
#include <iostream>
#include <stdio.h>
#include <cstdlib>
#include <string>
using namespace std;

class queue
{
private:
struct queue_ob
{
string name;
string message;
string phoneNumber;
};

queue_ob *tail;
int size;

public:
queue(string s1, string s2, string s3)
{
size=1;
}
int stack_size()
{
return size;
}

void push(string s1, string s2, string s3)
{
if (size < 10)
{
size++;
queue_ob *temp=new(queue_ob);
tail=temp;
}
else
{
cout<<"The queue size is exceeded"<<endl; system("pause");
}
}

void pop(string *s1, string *s2, string *s3)
{
if(size == 0)
{
cout<<"Queue is clear- remove nothing!"<<endl;
return;
}

delete temp;
size--;
}

void peek(string *s1, string *s2, string *s3)
{
if(size == 0)
{
cout<<"Queue is clear!"<<endl;
return;
}
}

};
int main()
{
string name;
string message;
string phoneNumber;
int temp;
cout<<"Enter the name of first caller : ";
cin>>name;
cout<<"Enter the message of fisrt caller : ";
cin>>message;
cout<<"Enter the phone number of first caller";
cin>>phoneNumber;
queue a(name, message, phoneNumber);
do
{
system("cls");
cout<<"1. Add caller to queue"<<endl;
cout<<"2. Get the last caller of the queue"<<endl;
cout<<"3. Current size of the queue"<<endl;
cout<<"4. Close the program"<<endl;
cin>>temp;
switch(temp)
{
case 1:
{
cout<<"Enter the name : ";
cin>>name;
cout<<"Enter the message : ";
cin>>message;
cout<<"Enter the phone number :";
cin>>phoneNumber;
a.push(name, message, phoneNumber);
} break;
case 2:
{
a.pop(&name, &message, &phoneNumber);
cout<<"Last Caller"<<endl;
cout<<"Name : "<<name<<endl;
cout<<"Message : "<<message<<endl;
cout<<"Phone number : "<<phoneNumber<<endl;
system("pause");
} break;
case 3:
{
cout<<"Size of queue : "<<a.stack_size()<<endl;
system("pause");
} break;
case 4: break;
default: cout<<"Wrond input!!!"<<endl; system("pause"); break;

}
} while (temp != 4);
}
﻿

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!