Wait in Line You Must
Wow, they're back. Wow, what effects. And wow, what lines. It's the
afternoon of opening night, and the line for \textit{Jedi}\ is already
around the block. You feel very sorry for the poor person selling
tickets. Whoever it is probably wants to kill the next person who asks
for tickets in a Yoda voice.
They need to open up more ticket booths. You know it can't hurt,
but you start wondering how much it would help. You don't really
have much else to do while in line, so...
Write a program to simulate a multi-server queue. You should
find both the average length of the line and the wait time. The
simulation ends when all customers have been served.
When determining the average length of the line, include the empty
line while the last customer is being served. The wait time is the
length of time one person spends in line before reaching a server.
Input will consist of the number of servers (at most five) followed by
a series of real-valued inter-arrival and service times in minutes.
The input will be terminated by two zero values. You will be given no
more than twenty pairs.
The output should show the average length of the line and the average
wait time to two places after the decimal.
Assume the line is initially empty.
Number of servers: 1
Inter-arrival and service time: 0 \,3
Inter-arrival and service time: 1 \,2.5
Inter-arrival and service time: 3 \,0.5
Inter-arrival and service time: 0 \,0
The line's average length was 0.58, and people generally
waited 1.17 minutes before being served.
Number of servers: 2
Inter-arrival and service times: 0 \,5
Inter-arrival and service times: 1 \,3
Inter-arrival and service times: 1 \,4
Inter-arrival and service times: 1 \,2.5
Inter-arrival and service times: 1 \,6
Inter-arrival and service times: 1 \,1
Inter-arrival and service times: 0 \,0
The line's average length was 0.78, and people generally
waited 1.75 minutes before being served.
Number of servers: 2
Inter-arrival and service times: 0 \,2
Inter-arrival and service times: .2 \,3
Inter-arrival and service times: .3 \,1.8
Inter-arrival and service times: .6 \,2.5
Inter-arrival and service times: .1 \,4
Inter-arrival and service times: .5 \,.6
Inter-arrival and service times: .3 \,2
Inter-arrival and service times: .1 \,3
Inter-arrival and service times: .8 \,1
Inter-arrival and service times: 0 \,0
The line's average length was 2.37, and people generally
waited 2.84 minutes before being served.
Number of servers: 1
Inter-arrival and service times: 0 \,5
Inter-arrival and service times: 1 \,4
Inter-arrival and service times: 1 \,3
Inter-arrival and service times: 1 \,5
Inter-arrival and service times: 1 \,2
Inter-arrival and service times: 1 \,5
Inter-arrival and service times: 0 \,0
The line's average length was 1.96, and people generally
waited 7.83 minutes before being served.