C++ Code Please Using Queue  We can use a queue to simulate the flow of customers through a check-out line in a store. In this simulation we will have the following details: one check-out line the expected service time for each customer is one minute (However, they may have to wait in line before being serviced) between zero and two customers join the line every minute We can simulate the flow of customers through the line during a time period n minutes long using the following algorithm: Initialize the queue to empty. for ( minute = 0 ; minute < n ; ++minute ) {       if the queue is not empty, then remove the customer at the front of the queue.       Compute a random number k between 0 and 3.       If k is 1, then add one customer to the line.       If k is 2, then add two customers to the line.       Otherwise (if k is 0 or 3), do not add any customers to the line. } In addition, the algorithm will keep track of the following:   the total number of customers served the combined total wait time of all customers the maximum length of time any of these customers spent waiting in line Operations on the Queue for the Check-out Line Simulation Given a time of 5 minutes, the following demonstrates the operations on the queue:

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
100%

C++ Code Please Using Queue 

We can use a queue to simulate the flow of customers through a check-out line in a store. In this simulation we will have the following details:

  • one check-out line
  • the expected service time for each customer is one minute (However, they may have to wait in line before being serviced)
  • between zero and two customers join the line every minute

We can simulate the flow of customers through the line during a time period minutes long using the following algorithm:

Initialize the queue to empty.

for ( minute = 0 ; minute < n ; ++minute )

{

      if the queue is not empty, then remove the customer at the front of the queue.

      Compute a random number k between 0 and 3.

      If k is 1, then add one customer to the line.

      If k is 2, then add two customers to the line.

      Otherwise (if k is 0 or 3), do not add any customers to the line.

}

In addition, the algorithm will keep track of the following:

 

  • the total number of customers served
  • the combined total wait time of all customers
  • the maximum length of time any of these customers spent waiting in line

Operations on the Queue for the Check-out Line Simulation

Given a time of 5 minutes, the following demonstrates the operations on the queue:

minute
queue operations
corresponding diagram
isempty?
yes
no degueue (empty queue)
1 engueue(0)
1
no
degueue
2 engueue(1)
engueue(1)
2
no
1
degueue
1
2 engueue(2)
engueue(2)
1
2
2
no
1
2
2 H2 .
degueue
1 engueue(3)
2 H 2
3
4
no
2
2
degueue
3
O no engueue (k=0)
2
3
Transcribed Image Text:minute queue operations corresponding diagram isempty? yes no degueue (empty queue) 1 engueue(0) 1 no degueue 2 engueue(1) engueue(1) 2 no 1 degueue 1 2 engueue(2) engueue(2) 1 2 2 no 1 2 2 H2 . degueue 1 engueue(3) 2 H 2 3 4 no 2 2 degueue 3 O no engueue (k=0) 2 3
Test Plan for "Check-out Line" Simulation Program
Total Number of
Time (minutes)
Average Wait Longest Wait
Customers Served
30
60
120
480
Transcribed Image Text:Test Plan for "Check-out Line" Simulation Program Total Number of Time (minutes) Average Wait Longest Wait Customers Served 30 60 120 480
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 4 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY