1 REM RETURN:4/28/80:REL. 1.0
2 REM COPYRIGHT CONTROL DATA  1980
20 DIM ZZCP$(36)
30 ZZCP$="COPYRIGHT  CONTROL  DATA  1980"
31 ZZ0=0:ZZ1=1:ZZ2=2:ZZ3=3:ZZ4=4:ZZ5=5:ZZ6=6:ZZ10=10:ZZ14=14:ZZ21=21:ZZ125=125:ZZ126=126:ZZ180=180:ZZ200=200
32 ZZ7=7:ZZ8=8:ZZ9=9:ZZ12=12:ZZ20=20:ZZ22=22:ZZ128=128:ZZ150=150:ZZ170=170:ZZ190=190:ZZ23=23:ZZ764=764:ZZFF=255
33 ZZDIS=PEEK(106)*256-961
35 DIM ZZSP$(ZZ10),ZZB1$(ZZ1):ZZB1$="}":ZZSP$="          "
36 GOTO 41
37 FOR ZZINDX=ZZ1 TO 400:NEXT ZZINDX:RETURN 
38 POKE 82,ZZ2:POKE 83,37:RETURN 
41 GOSUB 38:GRAPHICS ZZ2+16:SETCOLOR ZZ4,ZZ9,ZZ2:PLOT ZZ6,ZZ5:? #ZZ6;"ATARI"
42 GOSUB 37:GOSUB 37:GRAPHICS ZZ0
46 GOSUB ZZ126:GOSUB ZZ150:? ZZB1$
60 POSITION ZZ6,ZZ2:? "A CONTROL DATA CORPORATION":? :? " ",ZZSP$;"tm":? " "," CYBERWARE":? :? 
61 ? "     Personal Computer Product":POSITION ZZ2,13
62 ? ZZSP$;"  ****  ****":? ZZSP$;" *****  *****":? ZZSP$;"******  ******":? ZZSP$;"***        ***"
63 ? ZZSP$;"***        ***":? ZZSP$;"******  ******":? ZZSP$;" *****  *****":? ZZSP$;"  ****  ****"
70 GOSUB 37:? ZZB1$:? :? "STOCK RATE OF RETURN":? :? 
71 ? "This program computes the annual":? :? "rates of return compounded for an":? :? "investment."
80 DIM ZZER$(35),ZZQ1$(ZZ1),ZZQ2$(ZZ1),ZZB$(ZZ1)
82 ZZER$="ÅÒÒÏÒ - Invalid data. Resubmit it.":ZZB$="}":ZZEFLG=0:TRAP 110
83 DIM ZZBZ$(ZZ1):ZZBZ$=CHR$(253)
85 POSITION ZZ3,15:? ZZCP$:GOSUB ZZ180:GOSUB 300
90 ? ZZB$:GOSUB ZZ150:? :? "Type Ø if an expert user":? :? "     ÒÅÔÕÒÎ if a novice user":? 
91 GOSUB 128:INPUT ZZQ1$:IF ZZQ1$="X" THEN ? ZZB$:GOSUB 150:GOTO 450
100 GOSUB 140:? ZZB$:? "Type É for information about the":? "       program"
101 ? :? "     Ó for a Sample run":? :? "     ÒÅÔÕÒÎ to run a problem":? :GOSUB ZZ128
102 INPUT ZZQ2$:IF ZZQ2$="I" THEN GOSUB 155:? ZZB$:GOSUB 9000:GOTO 90
103 IF ZZQ2$="S" THEN ? ZZB$:GOSUB 145:GOTO 350
104 ? ZZB$:GOSUB ZZ150:GOTO 400
110 ZZGOTO=256*PEEK(187)+PEEK(186):ZZPEEK=PEEK(195):IF ZZPEEK=ZZ8 OR ZZPEEK=18 THEN GOSUB 170:TRAP 110:GOTO ZZGOTO
111 IF ZZPEEK<>ZZ3 AND ZZPEEK<>7 AND ZZPEEK<>11 THEN GOTO ZZGOTO
115 TRAP 110:? :? "ÅÒÒÏÒ - A result of a calculation   has exceeded the maximum allowable  value"
116 GOSUB ZZ180:GOTO 130
120 ? :? "The óèáäåä öáìõåó indicate those    that must be input by the user":? :RETURN 
125 POKE 752,ZZ0:RETURN 
126 POKE 752,ZZ1:RETURN 
128 POKE 764,255:GOSUB ZZ125:RETURN 
130 GOSUB 135:? ZZB$:? :? "End of problem"
131 ? :? "Type Ù to run another problem":? :? "     ÒÅÔÕÒÎ to exit to menu":? :GOSUB ZZ128:INPUT ZZQ1$
132 IF ZZQ1$<>"Y" THEN PRINT "}":TRAP 40000:POKE 752,1:POSITION 10,10:? " ÒÅÔÕÒÎÉÎÇ ÔÏ ÍÅÎÕ ":RUN "D:MENU"
133 RESTORE :GOTO 90
135 SETCOLOR ZZ2,16,ZZ12:SETCOLOR ZZ4,13,ZZ6:SETCOLOR ZZ1,ZZ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Z2,ZZ14:GOSUB 2400:GOSUB ZZ125
430 POSITION 13,19:INPUT Y1
435 IF Y1<ZZ0 OR Y1>9999 THEN GOSUB ZZ170:GOTO 430
440 GOSUB ZZ126:GOSUB ZZ190:GOSUB ZZ180
445 GOTO 515
450 POSITION ZZ2,ZZ1:? "No. of years and first year":? :? "(separated by a comma)":? :INPUT N,Y1
460 NM1=N-ZZ1:IF N<ZZ2 OR N>ZZ20 OR Y1<=ZZ0 THEN GOSUB ZZ170:GOTO 450
470 GOSUB ZZ126:GOSUB ZZ190:GOSUB ZZ180
515 GOSUB 2500
570 ZZP84=PEEK(84):FOR I=ZZ1 TO N
571 IF I<>11 THEN 580
572 POSITION ZZ4,ZZ21:? "Íïòå äáôá éó òåñõéòåä":GOSUB ZZ180:FOR ZZJJ=ZZ1 TO 16:POSITION ZZ0,ZZ8:? "œ":NEXT ZZJJ
575 ZZP84=ZZP84-ZZ10
580 POSITION ZZ2,ZZP84:PRINT "Year ";:ZZR1=Y1+I-ZZ1:ZZR8=-ZZ1:ZZR9=ZZ4:GOSUB ZZ200:GOSUB ZZ125
585 POSITION 15,ZZP84:INPUT DI,PI
586 IF DI<ZZ0 OR PI<ZZ0 THEN GOSUB ZZ170:GOTO 585
587 ZZP84=ZZP84+ZZ1:GOSUB ZZ126
588 QQQ=ZZP84:GOSUB ZZ190:ZZP84=QQQ
591 D(I)=DI:P(I)=PI:IF I=ZZ1 THEN D1(I)=DI
593 IF I>ZZ1 THEN D1(I)=DI+D1(I-ZZ1)
600 NEXT I
610 POSITION ZZ1,ZZ21:GOSUB ZZ126:GOSUB 2250:GOSUB 2700
630 FOR I=ZZ1 TO NM1:B=ZZ0:C=ZZ0:FOR J=I+ZZ1 TO N
660 C=C+D(J)
680 B=((P(J)-P(1))+C)/P(1)
820 W(I,J)=B*100:GOSUB 2600:NEXT J:NEXT I:GOSUB 180
870 SETCOLOR ZZ2,ZZ9,ZZ4:SETCOLOR ZZ4,ZZ4,ZZ2
880 ? ZZB$:GOSUB ZZ126:? "   PERCENT RETURN ON INVESTMENT":? "         COMPOUNDED ANNUALLY":GOSUB 2250:? 
910 POKE 82,ZZ1:FOR K=ZZ1 TO NM1 STEP ZZ4:KP3=K+ZZ3:IF KP3>NM1 THEN KP3=NM1
935 POSITION ZZ1,ZZ5:? "  TO";:FOR KKK=K TO KP3:ZZR1=Y1+KKK:ZZR8=-ZZ1:ZZR9=ZZ8:GOSUB ZZ200:NEXT KKK:? 
970 ? :? "FROM":? :FOR KK=ZZ1 TO KP3:ZZR1=Y1+KK-ZZ1:ZZR8=-ZZ1:ZZR9=ZZ4:GOSUB ZZ200:FOR KKK=K TO KP3
980 IF KKK<KK THEN ? "        ";:GOTO 995
990 ZZR1=W(KK,KKK+ZZ1):ZZR9=ZZ5:ZZR8=ZZ2:GOSUB ZZ200
995 NEXT KKK:? 
1000 IF ZZ10*INT(KK/ZZ10)-KK<>ZZ0 THEN 1020
1005 IF KK=NM1 THEN 1030
1010 GOSUB 4010:FOR K10=ZZ1 TO ZZ10:POSITION ZZ1,ZZ9:? "œ":NEXT K10:POSITION ZZ1,ZZ9
1020 NEXT KK:IF K<>17 AND KP3<>NM1 THEN GOSUB 4010
1025 IF KP3<>NM1 THEN FOR K10=ZZ1 TO ZZ14:POSITION ZZ1,ZZ5:? "œ":NEXT K10
1030 NEXT K
1370 X=ZZ0:Y=ZZ0:V=ZZ0:GOSUB ZZ180
1380 SETCOLOR ZZ2,ZZ14,ZZ4:SETCOLOR ZZ4,12,ZZ6:? ZZB$:POKE 82,ZZ2:? " AVERAGE RETURN FOR EACH YEAR HELD"
1390 GOSUB 2250:? :FOR I=ZZ1 TO NM1:FOR J=I+ZZ1 TO N:XZ=W(I,J):X=XZ+X:Y=XZ+Y:NEXT J
1490 ? "Average return from";:ZZR1=Y1+I-ZZ1:ZZR8=-ZZ1:ZZR9=ZZ6:GOSUB ZZ200:? " = ";:ZZR1=X/(N-I):ZZR8=ZZ2:ZZR9=ZZ4
1500 GOSUB ZZ200:IF I<>12 THEN 1530
1505 GOSUB 4010:FOR K10=ZZ1 TO 13:POSITION ZZ2,ZZ3:? "œ":NEXT K10:POSITION ZZ2,ZZ3
1530 V=N-I+V:? :X=ZZ0:NEXT I:? :ZZR1=Y/V:GOSUB 2250
1580 ? "Average return for":? "all holding periods  ";:ZZR9=11:GOSUB ZZ200
1670 GOSUB ZZ180:SETCOLOR ZZ4,ZZ9,ZZ4:SETCOLOR ZZ2,ZZ14,ZZ2:? ZZB$:PRINT "HOLDING      ARITHMETIC "
1680 ? "PERIOD IN    AVERAGE   STAND. COEFF"
1690 ? "YEARS        RETURN    DEV.   VAR."
1691 ? ZZSP$;"     %        %      %"
1720 ? :V3=ZZ0:N2=ZZ0:X2=ZZ0:Y2=ZZ0:V2=ZZ0:FOR I=ZZ1 TO NM1:FOR J=ZZ1 TO N:IF J+I>N THEN 1850
1820 XZ=W(J,J+I):X2=XZ+X2:V2=XZ+V2:NEXT J
1850 X2=X2/(J-ZZ1):FOR J=ZZ1 TO N:IF J+I>N THEN 1920
1890 WA=W(J,J+I):WB=WA-X2:Y2=WB*WB+Y2:V3=WA*WA+V3:NEXT J
1920 Y2=SQR(Y2/(J-ZZ1)):ZZR1=I:ZZR8=-ZZ1:ZZR9=ZZ5:GOSUB ZZ200
1930 ? "    ";:ZZR1=X2:ZZR8=ZZ2:ZZR9=ZZ6:GOSUB ZZ200:ZZR1=Y2:GOSUB 200
1940 ZZR1=0:IF X2<>0 THEN ZZR1=Y2/X2
1960 ZZR9=ZZ4:GOSUB ZZ200:? 
1970 X2=ZZ0:Y2=ZZ0:C3=ZZ0
1980 IF I<>13 THEN 2010
1990 GOSUB 4010:FOR K10=ZZ1 TO ZZ14:POSITION ZZ2,ZZ6:? "œ":NEXT K10:POSITION ZZ2,ZZ6
2010 NEXT I:IF V-ZZ1=ZZ0 THEN 2020
2015 C3=SQR((V*V3-V2*V2)/V/(V-ZZ1))
2020 ? :? "All holding":? "periods";:ZZR1=V2/V:ZZR9=ZZ8:GOSUB ZZ200:ZZR1=C3:ZZR9=ZZ6:GOSUB ZZ200
2030 ZZR1=C3/(V2/V):ZZR9=ZZ4:GOSUB ZZ200:POSITION ZZ1,ZZ22:GOSUB 2250:GOSUB ZZ180:GOTO 130
2250 FOR I=ZZ1 TO 35:? "-";:NEXT I:? :RETURN 
2300 ? ZZB$:? "Enter the number of years for which":? "you have data.":? 
2310 ? "Note  Î years of data will provide":? "a base year and Î­± years of annual":? "returns.":? 
2340 ? "The value for years must be greater than 1 and less than 21.":? :? :? "Number of years ";:RETURN 
2400 ? :? "Enter the first year for which you"
2410 ? "wish to provide data.":? :? :? "First year ";:RETURN 
2500 ? ZZB$:? "Enter (separated by a comma)":? "  .  Dividend Per Share (DPS)"
2510 ? "  .  Closing Security Price (CSP)":? "for each of the following ";N;" years.":? 
2540 ? ZZSP$;"    DPS,  CSP":? :RETURN 
2600 POSITION ZZ2,23:? "Calculation is ";:ZZR1=DTC*100:ZZR8=-ZZ1:ZZR9=ZZ3:GOSUB 200:? "% complete";
2610 DTC=DTC+DTX:RETURN 
2700 DT=ZZ0:FOR I=ZZ1 TO NM1:FOR J=I+ZZ1 TO N:DT=DT+ZZ1:NEXT J:NEXT I:DTC=ZZ0:DTX=ZZ1/DT:GOSUB 2600:RETURN 
4010 GOSUB 180:POSITION ZZ2,ZZ23:? "œ";:RETURN 
9000 ? ZZB$:POSITION 7,ZZ1:? "STOCK RATE OF RETURN":? 
9010 ? :? "This program computes and displays":? :? "annual rates of return, compounded"
9020 ? :? "annually, for an investment.":? :? :? 
9025 ? "It is a modification of RETURN":? :? "     by J. Rocus":? :? " Amos Tuck School of Business"
9035 GOSUB 9400:? "It lets the user analyze the per-":? 
9040 ? "formance of a stock over a period":? :? "of years.":? :? 
9045 ? "It uses the dividends per share":? :? "and the closing stock price to":? 
9050 ? "compute the return rates.":? :? :? "It assumes that all dividends are"
9060 ? :? "reinvested in the same stock.":? 
9070 GOSUB 9400:? " INPUTS":? :? :? ".  Number of years of data":? :? ".  Starting year"
9080 ? :? :? ".  For each year requested":? :? "   .  Dividend Per Share (DPS)":? 
9090 ? "   .  Closing Security Price (CSP)":GOSUB 9400
9100 ? "OUTPUTS":? :? "The outputs are presented as tables.":? :? :? ".  Average annual return.":? 
9110 ? ".  Arithmetic average return for":? "   each year":? 
9120 ? ".  Average rate of return for all":? "   possible holding periods":? 
9130 ? ".  Standard deviations":? :? ".  Coefficients of variation":GOSUB 9400:RETURN 
9400 GOSUB ZZ180:? ZZB$:RETURN 
