1 REM EXPVAL
10 CLS:PRINT TAB(10); "EXPECTED VALUE ANALYSIS":PRINT
20 PRINT"THERE ARE MANY SITUATIONS FOR WHICH THE FINAL RESULT IS
30 PRINT"A MONETARY PAYOFF BUT FOR WHICH THE AMOUNT OF THE PAYOFF
35 PRINT"IS UNCERTAIN. IF WE CAN SOMEHOW MAKE A LIST OF THE POSSIBLE
40 PRINT"PAYOFFS AND THEIR RELATIVE LIKELIHOODS OF OCCURRENCE THEN
45 PRINT"THE CONCEPT OF EXPECTED VALUE MAY BE USED TO COMPUTE AN
50 PRINT"'AVERAGE' PAYOFF. THE PRESENT PROGRAM COMPUTES THE EXPECTED 
55 PRINT"VALUE OR AVERAGE PAYOFF OF A SITUATION AS THE ABOVE.
60 PRINT"INPUT INCLUDES A PAYOFF AND A PROBABILITY FOR EACH
65 PRINT"POSSIBLE RESULT. THE PROBABILITY IS A NUMBER BETWEEN 0 AND 1
70 PRINT"REPRESENTING LIKELIHOOD OF OCCURRENCE. THE PROBABILITIES
75 PRINT"SHOULD REALLY SUM TO 1 BUT THE PROGRAM WILL NORMALIZE THEM.
80 PRINT"THUS,E.G. THE USER MUST ONLY NOTE THAT A PROBABILITY OF .4
85 PRINT"MEANS TWICE AS LIKELY TO OCCUR AS A PROBABILITY O .2 .
90 INPUT"PRESS ENTER TO BEGIN";Z9$
100 CLS
105 CLEAR 1000
110  DIM  A(100),PP(100),PC(100)
120 PRINT"FOR EACH POSSIBLE PAYOFF INPUT PAYOFF AMOUNT AND PROBAILITY.
130 PRINT"INPUT 0,0 TO COMPLETE ENTRY AND TO DO COMPUTATION."
140 PRINT
150 N=0
160 PRINT"ENTRY";N+1;:INPUT"ENTER PAYOFF,PROBAILITY (0,0 TO END)";A(N+1),PP(N+1)
170 IF A(N+1)=0 AND PP(N+1)=0 THEN GOTO 200 ' ALL DONE
180 N=N+1:P=P+PP(N):REM TOTAL OF PROBABILITIES
190 GOTO 160
200 REM END UP COMPUTATION
210 FOR I=1 TO N:PC(I)=PP(I)/P:NEXT:REM STANDARDIZED PROBABILITIES
220 EX=0
230 FOR I=1 TO N:EX=EX+A(I)*PC(I):NEXT:REM EX = EXPECTED VALUE
240 F$(1)="ENTRY    VALUE        PROB.      PROB.       ENTRY     
245 F$(2)="                      ENTERED    STANDARD    EXP VAL"
250 F$(3)=" ###  #######.##       #.###       #.###     ######.##        ###.##"
255 F$(4)="               EXPECTED VALUE EQUALS         ######.##"
260 INPUT"IS LINE PRINTER OUTPUT DESIRED(Y/N)";Z2$
270 IF Z2$<>"Y" AND Z2$<>"N" THEN GOSUB 10000:GOTO 260
300 REM PRINTOUT
310 CLS:PRINT F$(1):PRINT F$(2)
320 IF Z2$="Y" THEN LPRINT F$(1):LPRINT F$(2):LPRINT " "
330 FOR I=1 TO N
340 PRINT USING F$(3);I,A(I),PP(I),PC(I),A(I)*PC(I)
350 IF Z2$="Y" THEN LPRINT USING F$(3);I,A(I),PP(I),PC(I),A(I)*PC(I)
355 IF I/12=INT(I/12) THEN PRINT:GOSUB 10100:PRINT
360 NEXT I
390 PRINT:LPRINT" "
400 PRINT USING F$(4);EX:IF Z2$="Y" THEN LPRINT USING F$(4);EX
410 PRINT
420 INPUT"ENTER 1 FOR MORE COMPUTATION,0 TO END";Z9$
425 CLS
430 IF Z9$="1" THEN GOTO 105
440 END
10000 PRINT"INPUT ERROR! TRY AGAIN!":FORQ=1TO300:NEXT:RETURN
10100 INPUT"PRESS ENTER TO CONTINUE";Z9$:RETURN
