1 REM BOND YIELD:7/22/80:REL. 1.1
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 ZZO
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$:? :? "BOND YIELD":? :? 
71 ? "This program computes the before":? :? "tax yield of a bond held to"
72 ? :? "maturity. "
80 DIM ZZER$(35),ZZQ1$(ZZ1),ZZQ2$(ZZ1),ZZB$(ZZ1),B$(30)
81 FOR I=1 TO 30:B$(I)=" ":NEXT I
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 ? "}":TRAP 40000:POKE 752,1:POSITION 10,10:? " ÒÅÔÕÒÎÉÎÇ ÔÏ ÍÅÎÕ ":RUN "D:MENU"
133 RESTORE :GOTO 90
135 SETCOLOR ZZ2,16,ZZ12:SET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THEN ZZR3=ZZR3*0.1:ZZR4=ZZR4+ZZ1:GOTO 203
204 ZZLB=ZZR9-ZZ1-ZZR4:IF ZZR6>=ZZ0 THEN ZZLB=ZZLB+ZZ1
205 IF ZZLB>ZZ0 AND ABS(ZZR6)<ZZ1 THEN ZZLB=ZZLB-ZZ1:ZZR3=ZZR3*0.1
206 IF ZZLB>ZZ0 THEN FOR ZZI=ZZ1 TO ZZLB:? " ";:NEXT ZZI
207 ZZDPT=ZZR9+ZZ1:ZZLOP=ZZR2+ZZR9:IF ZZLB>ZZ0 THEN ZZLOP=ZZLOP-ZZLB:ZZDPT=ZZDPT-ZZLB
208 FOR ZZI=ZZ1 TO ZZLOP:IF ZZR6<ZZ0 AND ZZI=ZZ1 THEN ? "-";:GOTO 212
209 IF ZZI=ZZDPT THEN ? ".";
210 IF ZZLB<ZZ0 THEN ? "*";:GOTO 212
211 ZZR3=ZZR3*ZZ10:ZZINT=INT(ZZR3):ZZR3=ZZR3-ZZINT:? ZZINT;
212 NEXT ZZI:RETURN 
300 DIM A$(3),Y$(32),C$(1),R(15),Q$(4),D1$(7),P1$(30),P2$(65),P3$(60),P4$(30),P5$(70)
310 DIM P6$(36),T1$(40),SP$(7)
315 P1$="Annual coupon (dollars)   ":P2$="Redemption price at                 maturity (dollars)        "
320 P3$="Maturity (years,months)   ":P4$="Present price (dollars)   "
330 P6$="Enter the following data items:"
335 D1$="    .  ":SP$="       "
340 RETURN 
350 K2=15:K3=45:? ZZB$
360 READ C,R,P,M1,M2
370 DATA 6,100,104.45,12,5
375 GOSUB 145:? ZZB$:? :GOSUB 120:? :? P6$:? 
380 ? P1$;"¶":? :? P2$;"±°°":? :? P4$;"±°´®´µ":? :? P3$;"±²¬µ":? 
385 GOSUB 180:GOTO 490
400 GOSUB 150:? ZZB$:? P6$
410 POSITION 2,4:? P1$;:INPUT C:? 
411 IF C<0 THEN ? ZZBZ$:POSITION 28,4:? B$:GOTO 410
415 GOSUB 190
420 POSITION 2,6:? P2$;:INPUT R:? 
422 IF R<=0 THEN ? ZZBZ$:POSITION 28,7:? B$:GOTO 420
425 GOSUB 190
430 POSITION 2,9:? P4$;:INPUT P:? 
431 IF P<=0 THEN ? ZZBZ$:POSITION 28,9:? B$:GOTO 430
433 GOSUB 190
435 POSITION 2,11:? P3$;:INPUT M1,M2:? 
436 IF M1<0 OR M2<0 THEN ? ZZBZ$:POSITION 28,11:? B$:GOTO 435
438 GOSUB 190:GOSUB 180:GOTO 490
450 GOSUB 150:? ZZB$
460 ? "Enter data (separated by commas):":? :? SP$;"annual coupon":? :? SP$;"maturity price":? 
465 ? SP$;"present price":? :? SP$;"maturity (y,m)":? 
485 POSITION 8,15:INPUT C,R,P,M1,M2
486 IF C<0 OR R<=0 OR P<=0 OR M1<0 OR M2<0 THEN ? ZZBZ$:POSITION 8,15:? B$(1,29):GOTO 485
488 GOSUB 190:GOSUB 180
490 GOSUB 140:GOSUB 126:? ZZB$:? "Coupon         $";:ZZR1=C:ZZR8=2:ZZR9=7:GOSUB 200:? :? 
495 ? "Redemption     $";:ZZR1=R:GOSUB 200:? :? 
500 ? "Present price  $";:ZZR1=P:GOSUB 200:? :? 
505 ? "Maturity ";SP$;:ZZR1=M1:GOSUB 200:? " year(s)":? "  ";SP$;SP$;:ZZR1=M2:GOSUB 200:? " month(s)":? 
517 POSITION 3,22:? "     The program is computing."
518 POSITION 2,17
525 C=C/2:M3=M1*2+M2/6:M4=INT(M3):M5=M3-M4
530 D=0:IF P>=R THEN D=(P-R)/(M4+1)
535 B=P-D*(M4+1):U1=P+C*(1-M5):U2=R
540 IF M3>6 THEN GOSUB 700:GOTO 546
545 GOSUB 790
546 IF R=0 OR P=0 THEN LET Y=0:GOTO 560
550 Y=2*(EXP(Y)-1)
560 POSITION 2,16:? "YIELD":? "-----":? "   Before taxes ";:ZZR1=Y*100:GOSUB 200:? " percent"
640 POSITION 2,21:? "œ":POSITION 2,21:? "œ"
660 GOSUB 180:GOTO 130
690 END 
700 Y=1E-04
710 GOSUB 2000
720 D=Q-(V1+V2+C)
730 IF ABS(D/V3)<5E-08 THEN 760
740 Y=Y-D/V3
750 GO TO 710
760 RETURN 
790 Y=1E-04
800 GOSUB 860
810 D=Q-(V1+V2)
820 IF ABS(D/V3)<5E-08 THEN 850
830 Y=Y-D/V3:GOTO 800
850 RETURN 
860 V1=0:V3=0:Q=U1:EYM3=EXP(-Y*M3):V2=U2*EYM3
890 FOR I=0 TO M4
900 J=M5+I:EJ=EXP(-Y*J):V1=V1+C*EJ:V3=V3+J*EJ:NEXT I
930 V3=V3+M3*U2*EYM3
940 RETURN 
2000 Q=U1*EXP(Y*M5):EY=EXP(Y):EYM1=EY-1:EYM12=EYM1*EYM1:M41=M4-1:EYM41=EXP(Y*M41)
2005 EM4Y=EXP(-M4*Y)
2010 V1=C*(1-EM4Y)/EYM1
2020 V2=U2*EM4Y
2030 V3=V2*M4-P*M5
2040 V3=V3+(C/EYM12)*(EY-(M4/EYM41))
2050 V3=V3+(C/EYM12)*(M41/EYM41):RETURN 
9000 ? "BOND YIELD":? :? "This program computes the yield to":? :? "maturity of a bond. No tax"
9010 ? :? "computations are provided."
9030 ? :? :? :? "It is a modification of BONDYD":? :? "by Prof. J. Peter Williamson,":? 
9040 ? "Amos Tuck School of BusinesS.":GOSUB 180
9120 ? "The user must supply the following":? :? "data. All data must be numeric.":? :? 
9130 ? :? D1$;"Annual coupon payment":? SP$;"(dollars)":? 
9140 ? D1$;"Redemption price at maturity":? SP$;"(dollars)":? 
9150 ? D1$;"Time to maturity (years and":? SP$;"months)":? ""
9160 ? D1$;"Present price (dollars)":? ""
9360 GOSUB 180:? "NOTE:":? :? 
9370 ? "When an input request requires":? :? "multiple values, the computer will":? 
9380 ? "continue to prompt (with a ?),":? :? "until it has received sufficient":? :? "values."
9390 GOSUB 180:RETURN 
