
Wentworth Institute of Technology
Division of Professional and Continuing Studies
COMP380 Section 71 - Data Structures I - Spring, 2007
Homework 11 – Toll Booth Simulation (Queues)
Instructor: Bob Goldstein (617) 912-2512
bob.goldstein@schepens.harvard.edu
http://home.comcast.net/~goldsteinr/Courses/index.html
http://goldstein.eri.harvard.edu/courses/index.html
http://myweb.wit.edu/goldsteinr/Courses/index.html
Due Date: May 1, 2007 (two weeks)
Hand In: Printout of program code and dialogue of how it runs.
Purpose: Use queues to simulate a toll booth plaza
1. You will write a program similar to the “Bank Queue” simulation we did in class, but instead of
banks, you will simulate a toll booth plaza.
2. Your simulation will be designed to answer the question “When is the appropriate time to change
a “cash” toll booth lane to a “fast lane” toll booth lane.
3. This particular plaza has a total of four toll booths. There is initially a single “fast lane” toll booth
and three “cash” toll booths. HOWEVER, write your program so that at the beginning of the run,
you can designate each toll booth to be either type.
4. Set up the following constants at the beginning of your simulation, that can be changed each time
the simulation will run:
a. NUM_CARS – the number of cars generated for the duration of the simulation
b. TRANS_TIME_FOR_CASH – transaction time for a cash car to go through
c. TRANS_TIME_FOR_FAST – transaction time for a fast-lane car
d. CASH_TO_FAST_RATIO – ratio of cash cars to fast-lane cars.
e. CAR_GENERATION_FREQUENCY – how often a car will be “generated”
5. When a car is generated, it will be generated either as a cash car or a “fast-lane” car. A “fast-lane”
car can use only the fast-lane booths, and a cash car can only use the fast-lane booths.
6. Run the simulation with various CASH_TO_FAST_RATIOs, and plot the length of the fast lane
queue at the end of the run versus this ratio. When the length of the fast-lane toll booth becomes
double that of the average of the cash toll booths, that is when you need to change a cash to a fast-
lane.
7. Run the simulation one more time, making the change so that there are two toll booths of each
type, and see how the lengths of the queues at the end of the run is changed by making this
alteration.
Extra Credit:
1. Use your simulation to answer the question “do we need to increase the number of toll
booths?”.
2. Alter the rules of use so that a “fast-lane” car can use a “cash” booth if the queue size is
too long at the “fast-lane” booth.
/app/work/qkd6c9-451191-2765028-homework11-doc.doc 1 12/1/2020 12/1/2020