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 "PROGRAM WE EXAMINE THE CHANGE IN COSTS DUE TO INCREASING THE  
55 PRINT "SERVICE RATE BY ADDING SERVERS TO THE SYSTEM.   
60 PRINT "THE APPROPRAIATE PARAMETERS ARE:  
65 PRINT "MEAN ARRIVAL RATE OF UNITS(CUSTOMERS) INTO OUR SYSTEM.  
70 PRINT "MEAN SERVICE RATE CAPABILITY BY 1 SERVER.  
75 PRINT "COST PER UNIT TIME PER SERVER  
80 PRINT "OPPORTUNITY COST PER UNIT TIME PER ITEM ON QUEUE.  
85 GOSUB  10100  
90 PRINT "BY THE WAY, A QUEUE IS A WAITING LINE.  
95 PRINT :PRINT "THE OUTPUT OF THE SYSTEM IS A TABLE GIVING TOTAL COST  
100 PRINT "OF THE SYSTEM USING VARIOUS NUMBERS OF SERVERS.  
190 PRINT :INPUT "PRESS ENTER TO CONTINUE";Z9$  
200 CLS  
210 PRINT "THE MEAN SERVICE RATE IS THE SPEED AT WHICH 1 SERVER CAN  
220 PRINT "HANDLE ITEMS NEEDING SERVICE IF HE IS ALWAYS BUSY.  
230 PRINT :PRINT "THE MEAN ARRIVAL IS THE AVERAGE RATE(PER UNIT TIME)  
240 PRINT "AT WHICH ITEMS ARRIVE  FOR SERVICE INTO THE SYSTEM  
250 PRINT   
260 INPUT "ENTER MEAN SERVICE RATE(ITEMS PER UNIT TIME) ";S  
270 INPUT "ENTER MEAN ARRIVAL RATE(ITEMS PER UNIT TIME) ";A  
280 PRINT "ENTER WAITING LINE COST($ PER ITEM ON LINE                                 PER UNIT TIME                     ";:INPUT  CW  
290 PRINT "ENTER COST OF A SERVER($ PER UNIT TIME)      ";:INPUT  CS  
300 DEFDBL  F:DIM  F(30)  
305 DIM  LQ(30)  
310 F(0)=1:F=1:FOR  I=1 TO 30:F(I)=F*F(I-1):F=F+1:NEXT   
320 K=1  
330 IF   A<K*S  THEN  GOTO  400  
340 K=K+1:GOTO  330  
400 REM FIRST K VALID: ALL OTHER NUMBERS OF SERVERS TOO SMALL  
410 FOR  J=K  TO  K+5:LQ(J)=A*S*(A/S)[J/(F(J-1)*(J*S-A)[2)  
420 P0=0:FOR  L=0  TO  J-1:P0=P0+(A/S)[L/F(L):NEXT  L:P0=P0 + 1/F(J)*(A/S)[J*(K*S/(K*S-A)):P0=1/P0  
430 LQ(J)=LQ(J)*P0  
440 NEXT  J  
450 F$(1)="SERVERS   AVG. QUEUE    SERVER COST/  QUEUE COST/  TOTAL COST/  
460 F$(2)="            LENGTH       UNIT TIME     UNIT TIME   UNIT TIME"  
465 F$(3)="  ##       ####.##       ######.##    ######.##   ########.##"  
470 CLS  
475 PRINT  F$(1):PRINT  F$(2)  
480 FOR  J=K  TO  K+5  
490 PRINT USING  F$(3);J,LQ(J),J*CS,LQ(J)*CW,J*CS+LQ(J)*CW  
500 NEXT  J  
520 PRINT :INPUT "PRESS ENTER FOR MORE COMPUTATION";Z9$  
522 IF Z9$ = "-1" THEN END
525 CLEAR  1000  
530 GOTO  200  
10100 INPUT "PRESS ENTER TO CONTINUE";Z9$:RETURN   
