10 REM PROGRAM EVUATION AND REVIEW TECHNIQUE (PERTH) 10/3/80 10:00 AM
20 REM  'A' ARRAY = START AND END NODES FOR EACH ACTIVITY
30 REM  'S' ARRAY = EARLY START TIMES FOR EACH ACTIVITY
40 REM  'F' ARRAY = LATE FINISH TIMES FOR EACH ACTIVITY
50 REM  'E' ARRAY = EXPECTED DURATIONS AND VARIANCES OF ACTIVITIES
60 DIM  A(100,2),S(100),F(100),E(100,2)
65 DEF FNR(Z1)=INT((Z1*1000+.5))/1000
70 PRINT "  PROGRAM EVALUATION"
80 PRINT " AND REVIEW TECHNIQUE"
90 PRINT
100 PRINT "   ENTER THE NUMBER OF "
110 PRINT "ACTIVITIES IN THIS NETWORK";
120 INPUT N
130 PRINT
140 FOR I=1 TO N
150 PRINT
160 PRINT "-----ACTIVITY";I;"-----"
170 PRINT "ENTER START NODE, END NODE";
180 INPUT A(I,1),A(I,2)
190 IF A(I,2)<=A(I,1) THEN 220
200 IF A(I,2)<N THEN 280
220 PRINT " START NODE MUST BE NUMBERED LOWER"
230 PRINT "  THAN END NODE, AND END NODE MUST"
240 PRINT "BE LESS THAN THE NUMBER OF ACTIVITIES."
250 PRINT "     *** TRY ENTRY AGAIN ***"
260 PRINT
270 GOTO 150
280 PRINT "ENTRE THREE TIME ESTIMATES"
290 PRINT "FOR THIS ACTIVITY (A,M,B)";
300 INPUT A1,M,B
310 REM E(I,1) IS THE EXPECTED DURATION 
320 E(I,1)=FNR((A1+M*4+B)/6)
330 REM E(I,2) IF THE ACTIVITY VARIANCE
340 E(I,2)=FNR((B-A1)/6)^2
350 S(I)=0
360 F(I)=0
370 NEXT I
380 REM LOOP TO FIND EARLY START TIMES FOR NETWORK
390 FOR I=1 TO N
400 IF S(A(I,2))>=S(A(I,1))+E(I,1) THEN 420
410 S(A(I,2))=S(A(I,1))+E(I,1)
420 NEXT I
430 F(A(N,2))=S(A(N,2))
440 REM LOOP TO CALCULATE LATE FINISH TIMES FOR NETWORK
450 FOR I=N TO 1 STEP -1
460 IF F(A(I,1))=0 THEN 490
470 IF F(A(I,1))>F(A(I,2))-E(I,1) THEN 490
480 GOTO 500
490 F(A(I,1))=F(A(I,2))-E(I,1)
500 NEXT I
510 V=0
520 C=0
530 L=0
540 FOR I=1 TO N
550 REM CALCULATE SLACK TIME IN S1
560 S1=F(A(I,2))-S(A(I,1))-E(I,1)
570 INPUT "-------------------------------- RETURN -------";X$
580 PRINT
590 PRINT "ACTIVITY";I;"(NODE";A(I,1);"TO NODE";A(I,2);")"
600 PRINT "IS A ";
610 IF S1<=0 THEN 630
620 PRINT "NON-";
630 PRINT "CRITICAL EVENT."
640 PRINT "EXPECTED DURATION:";E(I,1);"  STD. DEVIATION:";
650 PRINT SQR(E(I,2))
660 IF S1>0 THEN 740
670 PRINT " START NO LATER THAN:";S(A(I,1))
680 PRINT "MUST BE COMPLETED BY:";F(A(I,2))
690 REM ACCUMULATE PATH LENGTH IN L, VARIANCE IN V
700 IF L>=F(A(I,2)) THEN 720
710 L=F(A(I,2))
720 V=V+E(I,2)
730 GOTO 790
740 PRINT "EARLY START:";S(A(I,1));TAB(25);"LATE START:";
750 PRINT F(A(I,2))-E(I,1)
760 PRINT "EARLY FINISH:";S(A(I,1))+E(I,1);TAB(24);
770 PRINT "LATE FINISH:";F(A(I,2))
780 PRINT "SLACK TIME:";S1
790 NEXT I
800 PRINT
810 PRINT "THE CRITICAL PATH LENGTH IS ";L
820 P=SQR(V)
830 PRINT "PLUS OR MINUS";P
840 PRINT "ENTER DESIRED COMPLETION TIME(0 TO END)";
850 INPUT D
860 IF D<=0 THEN 1010
870 REM CALCULATE Z-SCORE FOR DESIRED DURATION
880 Y=(D-L)/P
890 REM CALCULATE CUMULATIVE AREA UNDER NORMAL DISTRIBUTION
900 REM REFERENCE: SOME COMMON BASIC PROGRAMS, 3RD ED. P. 128
910 R=EXP(-(Y^2)/2)/2.506628275#
920 Z=Y
930 Y=1/(1+.33267*ABS(Y))
940 T=1-R*(.436184*Y-.120168*Y^2+.937298*Y^3)
950 IF Z>=0 THEN 970
960 T=(1-T)*100
970 PRINT "PROBABILITY OF COMPLETION WITH"
980 PRINT "DURATION OF";D;"IS";T;" %"
990 PRINT
1000 GOTO 840
1010 END
T)*100
970 PRINT 