Question

To be written in C++. A local movie theater has three ticket windows and two computerized...

To be written in C++. A local movie theater has three ticket windows and two computerized ticket kiosks. Some transactions, such as group discounts, can only be done at the ticket windows. An arriving customer looks at the lines, and chooses to stand in the shortest one that can handle his or her transaction. Group sales take four minutes to process. Normal ticket sales take two minutes at a window and three minutes at a kiosk. Internet ticket sales pickups take one minute at a kiosk and two minutes at a window. Write a simulation of this process, using queues to represent the five lines. The data set should consist of randomly arranged customer arrivals, with 5% group sales, 20% Internet ticket sales pickups, and 75% regular ticket sales. A data set will contain 200 customers. All of the customers tend to arrive shortly before the start of a movie, so we are simplifying the simulation to say that they all arrive at the same time. From this simulation, the theater wants you to determine the maximum length of each line, the average waiting time for each line, and the time required for each line to empty. As a hint, think about using a list to create the data set by adding 10 group, 40 Internet, and 150 regular customers and then shuffling the list. The list is then traversed, transferring each customer to the shortest queue that can handle the customer’s transaction.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The Code has been Explained in the comments

Please refer to screenshots for indentation

If any doubt please comment before downvote, will resolve asap.

Code:

#include <bits/stdc++.h>

using namespace std;
      
vector <string> generate_queue(){ // To generate random queue with given parameters
  
   vector <string> Q;
   for(int i = 0; i < 10; i++)                   // inserting 10% group
   {
       Q.push_back("Group");
   }
   for(int i = 0; i < 40; i++)                   //inserting 20% Internet
   {
       Q.push_back("Internet");
   }
   for(int i = 0; i < 150; i++)               //inserting 75% regular
   {
       Q.push_back("Regular");
   }

   random_shuffle ( Q.begin(), Q.end() );       // shuffling the queue
   return Q;

}

int main(){

   vector <string> Q = generate_queue();

   queue <string> W1;                    // Queue for 1st window
   queue <string> W2;                           // Queue for 2nd window
   queue <string> W3;                           // Queue for 3rd window

   queue <string> K1;                           // Queue for 1st Kiosk                          
   queue <string> K2;                           // Queue for 2nd Kiosk
   for(int i = 0; i < Q.size(); i++)
   {
       if(Q[i] == "Group")
       {
           if(W1.size() <= W2.size() && W1.size() <= W3.size())
           {
               W1.push("G");
           }
           else if(W2.size() <= W3.size())
           {
               W2.push("G");
           }
           else
           {
               W3.push("G");
           }
       }
       else if(Q[i] == "Regular")
       {
           if(W1.size() <= W2.size() && W1.size() <= W3.size() && W1.size() <= K1.size() && W1.size() <= K2.size())
           {
               W1.push("R");
           }
           else if(W2.size() <= W3.size() && W2.size() <= K2.size() && W2.size() <= K2.size())
           {
               W2.push("R");
           }
           else if(W3.size() <= K2.size() && W3.size() <= K2.size())
           {
               W3.push("R");  
           }
           else if(K1.size() <= K2.size())
           {
               K1.push("R");
           }
           else
           {
               K2.push("R");
           }

       }
       else if(Q[i] == "Internet")
       {
           if(W1.size() <= W2.size() && W1.size() <= W3.size() && W1.size() <= K1.size() && W1.size() <= K2.size())
           {
               W1.push("I");
           }
           else if(W2.size() <= W3.size() && W2.size() <= K2.size() && W2.size() <= K2.size())
           {
               W2.push("I");
           }
           else if(W3.size() <= K2.size() && W3.size() <= K2.size())
           {
               W3.push("I");  
           }
           else if(K1.size() <= K2.size())
           {
               K1.push("I");
           }
           else
           {
               K2.push("I");
           }
       }
   }

   cout << "Max queue size for window 1 : " << W1.size() << endl;
   cout << "Max queue size for window 2 : " << W2.size() << endl;
    cout << "Max queue size for window 3 : " << W3.size() << endl;
    cout << "Max queue size for Kiosk 1 : " << K1.size() << endl;
    cout << "Max queue size for Kiosk 2 : " << K2.size() << endl;

    int wait_time = 0;
    float avg_W1 = 0;
    int W1_len = W1.size();
    while(!W1.empty())                       // Processing Window 1
    {
        avg_W1 += wait_time;
        if(W1.front() == "G")
        {
            wait_time += 4;
        }
        else if(W1.front() == "R")
        {
            wait_time += 2;
        }
        else
        {
            wait_time += 2;
        }
        W1.pop();
    }
    avg_W1 = avg_W1/W1_len;
    int t2e_W1 = wait_time;

    wait_time = 0;
    float avg_W2 = 0;
    int W2_len = W2.size();
    while(!W2.empty())                       // Processing Window 2
    {
        avg_W2 += wait_time;
        if(W2.front() == "G")
        {
            wait_time += 4;
        }
        else if(W2.front() == "R")
        {
            wait_time += 2;
        }
        else
        {
            wait_time += 2;
        }
        W2.pop();
    }
    avg_W2 = avg_W2/W2_len;
    int t2e_W2 = wait_time;


    wait_time = 0;
    float avg_W3 = 0;
    int W3_len = W3.size();
    while(!W3.empty()) // Processing Window 3
    {
        avg_W3 += wait_time;
        if(W3.front() == "G")
        {
            wait_time += 4;
        }
        else if(W3.front() == "R")
        {
            wait_time += 2;
        }
        else
        {
            wait_time += 2;
        }
        W3.pop();
    }
    avg_W3 = avg_W3/W3_len;
    int t2e_W3 = wait_time;

    wait_time = 0;
    float avg_K1 = 0;
    int K1_len = K1.size();
    while(!K1.empty())                   // Processing Kiosk 1
    {
        avg_K1 += wait_time;
        if(K1.front() == "I")
        {
            wait_time += 1;
        }
        else {
            wait_time += 3;
        }
        K1.pop();
    }
    avg_K1 = avg_K1/K1_len;
    int t2e_K1 = wait_time;

    wait_time = 0;
    float avg_K2 = 0;
    int K2_len = K2.size();
    while(!K2.empty())                   // Processing Kiosk 2
    {
        avg_K2 += wait_time;
        if(K2.front() == "I")
        {
            wait_time += 1;
        }
        else {
            wait_time += 3;
        }
        K2.pop();
    }
    avg_K2 = avg_K2/K2_len;
    int t2e_K2 = wait_time;


    cout << "\nFor Window 1 : \n";
    cout << "Average Wait Time : " << avg_W1 << " \n";
   cout << "Time to empty : " << t2e_W1 << " \n";   
   cout << "\nFor Window 2 : \n";
    cout << "Average Wait Time : " << avg_W2 << " \n";
   cout << "Time to empty : " << t2e_W2 << " \n";   
   cout << "\nFor Window 3 : \n";
    cout << "Average Wait Time : " << avg_W3 << " \n";
   cout << "Time to empty : " << t2e_W3 << " \n";   
   cout << "\nFor Kiosk 1 : \n";
    cout << "Average Wait Time : " << avg_K1 << " \n";
   cout << "Time to empty : " << t2e_K1 << " \n";   
   cout << "\nFor Kiosk 2 : \n";
    cout << "Average Wait Time : " << avg_K2 << " \n";
   cout << "Time to empty : " << t2e_K2 << " \n";   
   return 0;
}

Screenshots:

Code:

Output:

Hope it helps

Add a comment
Know the answer?
Add Answer to:
To be written in C++. A local movie theater has three ticket windows and two computerized...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • A movie theater has four (4) auditoriums. Each of the four auditoriums plays a different film....

    A movie theater has four (4) auditoriums. Each of the four auditoriums plays a different film. The theater has a single ticket booth and a cashier who can maintain an average service rate of 280 movie patrons per hour. Patrons arrive at an average rate of 210 per hour and follow a Poisson distribution. Find the average number of moviegoers waiting in line to purchase a ticket. What percentage of the time is the cashier busy? What is the average...

  • Beate Klingenberg manages a​ Poughkeepsie, New​ York, movie theater complex called Cinema 8. Each of the...

    Beate Klingenberg manages a​ Poughkeepsie, New​ York, movie theater complex called Cinema 8. Each of the eight auditoriums plays a different​ film; the schedule staggers starting times to avoid the large crowds that would occur if all eight movies started at the same time. The theater has a single ticket booth and a cashier who can maintain an average service rate of 300 300 patrons per hour. Service times are assumed to follow a negative exponential distribution. Arrivals on a...

  • C++ Lists, and a little queuing theory The MegaMicroMart (a subsidiary of Fly-By-Night Industries) is planning...

    C++ Lists, and a little queuing theory The MegaMicroMart (a subsidiary of Fly-By-Night Industries) is planning their next Big Small-Box Store. They want to ensure good customer service, and you've been hired to do some simulations to advise them on how to set up their checkout lines. This is a discrete-time simulation. This means that for our purposes, time advances in discrete 'ticks'. Each tick, everyone who's going to arrive arrives all at once, while at the same time everyone...

  • Waiting lines Customers walk in at random to a deli. The interarrival times are exponentially dis...

    Waiting lines Customers walk in at random to a deli. The interarrival times are exponentially distributed with an average of 5 minutes. The deli prepares one order at a time. The order preparation times are exponentially distributed with an average of 3 minutes. 13. What kind of waiting line model is appropriate for the deli? 14. What is the utilization? 15. What is the total amount of time a customer would expect to spend at the deli (from walking in...

  • A local Walmart is adopting its new Corporate customer drive-through order pick-up program. Based on its...

    A local Walmart is adopting its new Corporate customer drive-through order pick-up program. Based on its serving region and demographics (households with smart phones, internet access, on-line shopping habits, etc.), it estimates that once launched, customers will arrive randomly according to a Poisson process with a mean hourly arrival rate of 100 cars per hour. This randomness will occur despite the fact that customers schedule a time window for their arrival. During their order pick up, some customers trust that...

  • Queues This programming exercise introduces the Queue data structure. The students must create all the necessary...

    Queues This programming exercise introduces the Queue data structure. The students must create all the necessary methods for the queue and use the queue in a Java program. Step 1 - Create a new project in Netbeans Use the following naming convention: “Module4_Lastname_Assignment1”. Step 2 - Build a solution You have been asked to create a customer service program for a new phone store that will be opening soon. Since this company anticipates being the agent for a rising new...

  • This is a c++ program. Use the description from Parking Ticket Simulator (listed below) as a basis, where you need to...

    This is a c++ program. Use the description from Parking Ticket Simulator (listed below) as a basis, where you need to create a Car class and Police Officer class, to create a new simulation. Write a simulation program (refer to the Bank Teller example listed below) that simulates cars entering a parking lot, paying for parking, and leaving the parking lot. The officer will randomly appear to survey the cars in the lot to ensure that no cars are parked...

  • Needs Help with Java programming language For this assignment, you need to write a simulation program...

    Needs Help with Java programming language For this assignment, you need to write a simulation program to determine the average waiting time at a grocery store checkout while varying the number of customers and the number of checkout lanes. Classes needed: SortedLinked List: Implement a generic sorted singly-linked list which contains all of the elements included in the unsorted linked list developed in class, but modifies it in the following way: • delete the addfirst, addlast, and add(index) methods and...

  • Java Project For this assignment, you will write a simulation program to determine the average waiting...

    Java Project For this assignment, you will write a simulation program to determine the average waiting time at a grocery store checkout while varying the number of customers and the number of checkout lanes. Classes needed: SortedLinked List: Implement a generic sorted singly-linked list which contains all of the elements included in the unsorted linked list developed in class, but modifies it in the following way: delete the addfirst, addlast, and add(index) methods and instead include a single add method...

  • Donna Shader, manager of the Winter Park Hotel, is considering how to restructure the front desk...

    Donna Shader, manager of the Winter Park Hotel, is considering how to restructure the front desk to reach an optimum level of staff efficiency and guest service. At present, the hotel has five clerks on duty, each with a separate waiting line, during the peak check-in time of 3:00 P.M. to 5:00 P.M. Observation of arrivals during this time show that an average of 90 guests arrive each hour (although there is no upward limit on the number that could...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT