1 REM QUEUE1
5 CLEAR 1000
10 CLS:PRINT TAB(10); "WAITING LINE ANALYSIS":PRINT
20 PRINT"WAITING LINES OCCUR IN ALMOST ANY SYSTEM FROM THE SUPERMARKET
25 PRINT"CHECKOUT COUNTER TO THE RUNWAY AT AN AIRPORT. IN ANALYZING
30 PRINT"A WAITING LINE SITUATION, ON THE ONE HAND LONG WAITING LINES
35 PRINT"CAUSE LOSS OF BUSINESS EVEN IF ONLY DUE TO CUSTOMER DISSAT-
40 PRINT"FACTION WHILE INCREASING SERVICE INCREASES COSTS. IN THIS
50 PRINT"WE ASSUME THERE IS A SINGLE SERVER(E.G. CHECKOUT PERSON),
55 PRINT"WHO CAN SERVE,ON AVERAGE, A GIVEN NUMBER OF CUSTOMERS PER
60 PRINT"TIME. THE CUSTOMERS ARRIVE RANDOMLY AT SOME OTHER AVERAGE RATE.
65 PRINT"THE WAITING LINE IS FIRST COME-FIRST SERVED. WE EXAMINE THE
70 PRINT"PROBABILISTIC CHARACTERISTICS OF THE WAITING LINE OR QUEUE
75 PRINT"AS IT IS GENERALLY CALLED. THE AVERAGE SERVICE RATE IS THE
80 PRINT"MEAN SERVICE RATE WHILE THE AVERAGE ARRIVAL RATE IS THE MEAN
85 PRINT"ARRIVAL RATE.
90 GOSUB 10100
95 CLS:PRINT"ONE REQUIREMENT IS THAT THE MEAN SERVICE RATE BE GREATER
100 PRINT"THAN THE MEAN ARRIVAL RATE. OTHERWISE THE QUEUE WOULD GET
105 PRINT"INFINITELY LONG. 
110 PRINT
115 PRINT"WHAT AVARAGE MEANS IS SOMETIMES LONGER,SOMETIMES SHORTER BUT
120 PRINT"IF SOMEONE LOKKED AT THE WAITING LINE EVERY DAY FOR A MONTH
125 PRINT"THEN THE AVERAGE(MEAN) QUEUE LENGTH FOR THE MONTH WOULD BE
130 PRINT"CLOSE TO WHAT WAS COMPUTED HERE."
190 INPUT"PRESS ENTER TO BEGIN";Z9$
200 CLS
210 PRINT"THE FOLLOWING ARE IN NUMBER PER UNIT TIME":PRINT
220 INPUT"     ENTER MEAN ARRIVAL RATE OF UNITS";A
230 INPUT"     ENTER MEAN SERVICE RATE OF UNITS";S
240 IF A<=0 OR S<=0 THEN PRINT"NO NEGATIVES ALLOWED":GOTO 220
250 IF S<A THEN PRINT"SERVICE RATE MUST AT LEAST EQUAL ARRIVAL RATE":PRINT:GOTO 220
260 LS=A/(S-A):LQ=A[2/(S*(S-A)):WS=1/(S-A):WQ=A*WS/S:PU=A/S
300 PRINT
310 PRINT"AVERAGE LENGTH OF THE QUEUE      = ";LQ
320 PRINT"AVERAGE LENGTH OF THE SYSTEM     = ";LS
330 PRINT"AVERAGE WAITING TIME ON QUEUE    = ";WQ
340 PRINT"AVERAGE TIME WAITING IN SYSTEM   = ";WS
350 PRINT"PROBABILITY SYSTEM IS BUSY       = ";PU
360 PRINT:PRINT"SYSTEM TIME IS WAITING TIME PLUS SERVICE TIME.
370 PRINT:INPUT"PRESS ENTER FOR MORE";Z9$
375 IF Z9$ = "-1" THEN END
380 CLS:GOTO 200
10100 INPUT"PRESS ENTER TO CONTINUE";Z9$:RETURN
