Question: C++ Please! A thumbs up and positive comment will be left for a complete response! Thank you! In this program, you will implement a FIFO

C++ Please! A thumbs up and positive comment will be left for a complete response! Thank you!

In this program, you will implement a FIFO or FCFS Queue.

The data:

Define a structure named Customer with four members:

CustomerName: 15-character string, which is the name of the customer

ArrivalTime: integer, which is the arrival time of the customer

ServiceTime: integer, which is the time point that the customer starts to be serviced

FinishTime: integer, which is the leaving time of the customer

Define a structure named FCFSQueue with two members:

CustomerList: an array of 100 elements of type Customer;

length: integer, which is the number of the customers in the queue.

This program has four functions:

function IsEmpty check whether the queue is empty or not. Return true if empty, otherwise return false;

function GetLength will returns the number of customers in the queue;

function Enqueue will insert a new customer to the tail of the queue;

function Dequeue will remove a customer from the head of the queue.

Your main program will test these functions.

INSTRUCTIONS

Step 1: define data types

Define a structure named Customer with four members:

CustomerName: 15-character string, which is the name of the customer

ArrivalTime: integer, which is the arrival time of the customer

ServiceTime: integer, which is the time point that the customer starts to be serviced

FinishTime: integer, which is the leaving time of the customer

Define a structure named FCFSQueue with two members:

CustomerList: an array of 100 elements of type Customer;

length: integer, which is the number of the customers in the queue.

Step 2: Functions

function IsEmpty check whether the queue is empty or not. Return true if empty, otherwise return false;

function prototype:

bool IsEmpty(FCFSQueue);

function definition:

bool IsEmpty(FCFSQueue queue)

{

//if queues member length is 0, return true; otherwise, return false

}

function GetLength will returns the number of customers in the queue;

function prototype:

int GetLength(FCFSQueue);

function definition:

int GetLength(FCFSQueue queue)

{

//return queues member length

}

function Enqueue will insert a new customer to the tail of the queue;

function prototype:

void Enqueue(FCFSQueue&, Customer);

function definition:

void Enqueue(FCFSQueue &queue, Customer cus)

{

/* Note: queues member length represents the number of customers in the queue, and these customers take the place (index) of 0 to length-1 of queues member CustomerList.*/

/* If queue is not full (think how you know whether the queue is full or not), insert cus to the tail of the queue (that is, the place (or index) length of queues member CustomerList, CustomerList[length]) and update the number of customers in the queue; otherwise, print out the queue is full.

}

function Dequeue will remove a customer from the head of the queue.

function prototype:

void Dequeue(FCFSQueue&, Customer&);

function definition:

void Dequeue(FCFSQueue &queue, Customer &cus)

{

/* Note: queues member length represents the number of customers in the queue, and these customers take the place (index) of 0 to length-1 of queues member CustomerList.*/

/* If queue is not empty, delete the first customer from the head of queue and save it to cus: save the first element of queues member CustomerList (that is, CustomerList[0]) to cus and shift the remaining customers (with the index 1 to length-1) one place earlier (with the index 0 to length-2) and update the number of customers in the queue; otherwise, print out the queue is empty.

}

Step 3: main function

1.) declare a variable myQueue of type FCFSQueue and initialize the length member to be 0, which means the queue is empty.

2.) Declare a variable newCus of type Customer and initialize it to :

CustomerName: Tom

ArrivalTime: 1

ServiceTime: 0

FinishTime: 0

3.) Call function Enqueue and insert newCus to myQueue

4.) Reset the value of newCus as follows:

CustomerName: Bob

ArrivalTime: 3

ServiceTime: 0

FinishTime: 0

5.) Call function Enqueue and insert newCus to myQueue

6.) Display all the customers name in myQueue

7.) Call function Dequeue and print out the name of the customer who is leaving

8.) Call function Dequeue and print out the name of the customer who is leaving

9.) Call function Dequeue and print out the name of the customer who is leaving, what happened? What is the output?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!