1 REM CONDPROF
5 CLEAR 1000
10 CLS:PRINT TAB(10);"CONDITIONAL PROFIT TABLE":PRINT
20 PRINT"THIS PROGRAM ASSUMES THERE ARE FROM 1 TO 6 STATES OF NATURE.
25 PRINT"THERE ARE ALSO FROM 1 TO 6 POSSIBLE ACTIONS WE CAN TAKE. IF THE
30 PRINT"STATE OF NATURE(S OF N) IS KNOWN THEN EACH ACTION LEADS TO
35 PRINT"A KNOWN MONETARY RESULT. THIS RESULT IS A CONDITIONAL PROFIT.
40 PRINT"FOR EXAMPLE, IF ACTION 3 LEADS TO A $35 PAYOFF WHEN STATE OF
45 PRINT"NATURE 4 IS TRUE THEN 35 IS THE CONDITIONAL PROFIT OF ACTION
50 PRINT"3 GIVEN STATE OF NATURE 4. THE FOLLOWING PROGRAM CONSTRUCTS
55 PRINT"A MATRIX WITH ELEMENTS BEING THE CONDITIONAL PROFITS.
60 PRINT"IN ADDITION THE PROBABILITY OF EACH S OF N IS ENTERED AND
70 PRINT"THE EXPECTED VALUE OF EACH ACTION IS COMPUTED.
95 PRINT:INPUT"PRESS ENTER TO BEGIN";Z9$
100 D=6:REM MAXIMUM DIMENSION
102 DIM AA(D+2,D+2),PP(D),EE(D)
105 P=0
110 CLS
120 INPUT"ENTER NUMBER OF POSSIBLE STATES OF NATURE";N
125 IF N<2 OR N>D OR N<>INT(N) THEN GOSUB 10000:GOTO 120
127 PRINT
130 FOR I=1 TO N
135 PRINT"ENTER PROBABILITY OF S OF N";I;:INPUT PP(I)
140 P=P+PP(I)
150 NEXT I
160 IF P=1 THEN PRINT:GOTO 200
170 PRINT:PRINT"PROBABILITIES DO NOT SUM TO 1."
175 INPUT"ENTER 1 TO STANDARDIZE,0 TO BEGIN OVER";Z9
180 IF Z9<>0 AND Z9<>1 THEN GOSUB 10000:GOTO 170
185 IF Z9=0 THEN GOTO 105
190 FOR I=1 TO N:PP(I)=PP(I)/P:NEXT:P=1
200 PRINT:INPUT"ENTER NUMBER OF POSSIBLE ACTIONS(<=5)";M
205 IF M<2 OR M>6 OR M<>INT(M) THEN GOSUB 10000:GOTO 200
210 PRINT "NO PAYOFF MORE THAN 9999.99":PRINT
220 FOR J=1 TO M
225 PRINT
230 PRINT"ACTION";J
240 FOR I=1 TO N
250 PRINT TAB(5);"PAYOFF WHEN S OF N IS";I;:INPUT AA(I,J)
260 NEXT I
270 NEXT J
300 REM COMPUTATION
310 CLS:PRINT @ 340,"COMPUTING"
400 FOR J=1 TO M
410 FOR I=1 TO N:EE(J)=EE(J)+AA(I,J)*PP(I):NEXT I:REM EXP. VAL. 
420 NEXT J
495 REM PRINT
500 CLS
510 F$(1)=" ACTION # "
515 F$(2)=" #####.## "
520 F$(3)=" CONDITIONAL PAYOFFS OF ACTION GIVEN S OF N "
521 F$(4)="S N  PR                  ACTION"
525 PRINT:INPUT"IS LINE PRINTER OUTPUT DESIRED(Y/N)";Z2$
527 IF Z2$<>"Y" AND Z2$<>"N" THEN GOSUB 10000:GOTO 525
530 PRINT F$(3):PRINT:PRINT F$(4):IF Z2$="Y" THEN LPRINT F$(3):LPRINT" ":LPRINT F$(4)
535 PRINT TAB(9);"";:FOR I=1 TO M:PRINT USING F$(1);I;:NEXT:PRINT
537 IF Z2$="Y" THEN LPRINT TAB(9);"";:FOR I=1 TO M:LPRINT USING  F$(1);I;:NEXT:LPRINT" "
540 FOR I=1 TO N
550 PRINT USING "##  #.## ";I,PP(I);
555 IF Z2$="Y" THEN LPRINT USING "##  #.## ";I,PP(I);
560 FOR J=1 TO M:PRINT USING F$(2);AA(I,J);:NEXT:PRINT
562 IF Z2$="Y" THEN FOR J=1 TO M:LPRINT USING F$(2);AA(I,J);:NEXT:LPRINT" "
563 NEXT
564 PRINT:IF Z2$="Y" THEN LPRINT" "
565 PRINT "EXP VAL.";TAB(9);"";:
570 IF Z2$="Y" THEN LPRINT "EXP VAL.";TAB(9);"";:
575 FOR I=1 TO M:PRINT USING F$(2);EE(I);:NEXT
580 IF Z2$="Y" THEN FOR I=1 TO M:LPRINT USING F$(2);EE(I);:NEXT
600 PRINT:END
10000 PRINT"INPUT ERROR!TRY AGAIN!":FOR JJ=1 TO 300:NEXT:RETURN
10100 INPUT"PRESS ENTER TO CONTINUE";Z9$:RETURN
