Data Structure Using C++ (Queue) C++ code (NOT JAVA C++ JUST) C++ PROGRAMMING LANGUAGE PLEASE :: 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:  use 1.png  this is for test the program ::  use 2.png nd you can use these thing :::: struct node { int data; node *next; node(int d,node *n=0) { data=d; next=n; } }; class stack { node *topp; public: stack(); void push(int el); bool pop(); int top(); bool top(int &el); //~stack(); //void operator=(stack &o); //stack(stack &o); }; stack::stack() { topp=0; } void stack::push(int el) { topp=new node(el,topp); } bool stack::pop() { if(topp==0) return false; node *t=topp; topp=topp->next; delete t; return true; } int stack::top() { if(topp!=0) return topp->data; } bool stack::top(int &el) { if(topp==0) return false; el=topp->data; return true; } please need a full code without any errors

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter2: Problem Solving Using C++using
Section2.1: Introduction To C++
Problem 10E: (Practice) You’re given the job of preparing a complete meal for five people next weekend. Determine...
icon
Related questions
Question

Data Structure Using C++ (Queue) C++ code (NOT JAVA C++ JUST)

C++ PROGRAMMING LANGUAGE PLEASE ::

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: 

use 1.png 

this is for test the program :: 

use 2.png

nd you can use these thing ::::

struct node { int data; node *next; node(int d,node *n=0) { data=d; next=n; } }; class stack { node *topp; public: stack(); void push(int el); bool pop(); int top(); bool top(int &el); //~stack(); //void operator=(stack &o); //stack(stack &o); }; stack::stack() { topp=0; } void stack::push(int el) { topp=new node(el,topp); } bool stack::pop() { if(topp==0) return false; node *t=topp; topp=topp->next; delete t; return true; } int stack::top() { if(topp!=0) return topp->data; } bool stack::top(int &el) { if(topp==0) return false; el=topp->data; return true; }

please need a full code without any errors

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
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
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Lists
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning