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,38: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$:? :? "Mortgage and Loan Analysis":? :? :? 
71 ? "This program provides a comparison of":? "different mortgage and loan terms."
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 REM 
100 GOSUB 140:? ZZB$:? "Type и for information about the":? "       program"
101 ? :? "     ретурн to run a problem":? :GOSUB ZZ128
102 INPUT ZZQ2$:IF ZZQ2$="I" THEN GOSUB 155:? ZZB$:GOSUB 9000:GOTO 90
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":? :GOSUB ZZ128:INPUT ZZQ1$
132 IF ZZQ1$<>"Y" THEN GRAPHICS ZZ0:TRAP 40000:END 
133 RESTORE :GOTO 90
135 SETCOLOR ZZ2,16,ZZ12:SETCOLOR ZZ4,13,ZZ6:SETCOLOR ZZ1,ZZ1,ZZ2:RETURN 
140 SETCOLOR ZZ2,13,ZZ2:SETCOLOR ZZ4,ZZ14,ZZ2:SETCOLOR ZZ1,ZZ0,ZZ12:RETURN 
145 SETCOLOR ZZ2,ZZ14,ZZ0:SETCOLOR ZZ4,ZZ14,ZZ8:SETCOLOR ZZ1,ZZ1,ZZ12:RETURN 
150 SETCOLOR ZZ2,ZZ9,ZZ2:SETCOLOR ZZ4,ZZ5,ZZ4:SETCOLOR ZZ1,ZZ0,ZZ12:RETURN 
155 SETCOLOR ZZ2,ZZ14,ZZ10:SETCOLOR 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1 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 T$(80),Z$(80),Z(10),R(10),Y(10),P(10),P$(80),A$(3)
310 RETURN 
400 GOTO 500
500 GOSUB 126:GOSUB 7000:POSITION 2,1:GOSUB 150
510 ? "MORTGAGE AMOUNTS TO BE CONSIDERED":? "_________________________________":? :? 
520 FLG=0:FLG2=0
530 FOR I=1 TO 10
540 GOSUB 125:PRINT "Amount(";I;")  ";
550 INPUT Z$:IF LEN(Z$)=0 AND I=1 THEN GOSUB 860:GOTO 530
560 IF LEN(Z$)=0 THEN GOTO 620
570 GOSUB 865:GOSUB 875
580 TRAP 4000:Z(I)=VAL(Z$)
590 Z0=I
600 NEXT I
620 ? "}":GOSUB 126:GOSUB 7000:POSITION 2,1:? 
630 ? "INTEREST RATES TO BE CONSIDERED":? "_______________________________":? 
640 SETCOLOR 2,10,2:SETCOLOR 4,13,4
650 FOR I=1 TO 10
660 GOSUB 125:? "Rate(";I;")  ";:INPUT Z$
670 IF LEN(Z$)=0 AND I=1 THEN GOSUB 860:GOTO 650
680 IF LEN(Z$)=0 THEN 740
685 GOSUB 865:GOSUB 875
690 GOSUB 865:GOSUB 875
700 TRAP 4010:R(I)=VAL(Z$)
710 R0=I
720 NEXT I
740 ? "}":GOSUB 126:GOSUB 7000:POSITION 2,2
750 SETCOLOR 2,2,2:SETCOLOR 4,0,6
760 ? "LIFE OF MORTGAGE IN YEARS"
770 ? "_________________________":? 
780 FOR I=1 TO 10
790 GOSUB 125:? "Years(";I;")  ";:INPUT Z$
800 IF LEN(Z$)=0 AND I=1 THEN GOSUB 860:GOTO 780
810 IF LEN(Z$)=0 THEN 980
820 GOSUB 865:GOSUB 875
830 TRAP 4020:Y(I)=VAL(Z$):Y0=I
840 NEXT I
850 GOTO 980
860 FLG=1
861 POSITION 3,21:PRINT "еррор - At least one value is               required":POSITION 2,5:RETURN 
865 IF FLG<>0 THEN POSITION 1,21:? "°":POSITION 2,6:FLG=0
866 RETURN 
870 POSITION 2,20:GOSUB 170:POSITION 2,5+I-1:RETURN 
875 GOSUB 190:POSITION 2,6+I-1:RETURN 
945 ? "and mortgage lives":GOSUB 180
980 TRAP 110:FOR Z1=1 TO Z0
981 GOSUB 5600:LIN=6
1050 A=Z(Z1)
1061 GOSUB 126
1090 FOR R9=1 TO R0
1092 R3=R(R9)/1200
1094 FOR Y3=1 TO Y0
1096 M9=1-(1/(1+R3)^(12*Y(Y3)))
1097 IF M9=0 THEN M=0:GOTO 1050
1098 M=A*R3/M9
1150 I1=M*12*Y(Y3)-A:IF I1<0 THEN I1=0
1160 ZZR1=R(R9):ZZR9=2:ZZR8=3:GOSUB 200
1180 ZZR1=Y(Y3):ZZR9=6:ZZR8=0:GOSUB 200:O9=FNP
1185 ZZR1=M:ZZR9=7:ZZR8=2:GOSUB 200
1190 ZZR1=I1:ZZR9=9:ZZR8=2:GOSUB 200:O9=FNP
1195 ? :GOSUB 5000
1280 NEXT Y3
1282 ? :GOSUB 5000
1284 NEXT R9
1288 IF Z1=Z0 THEN 1320
1290 IF LIN<>6 THEN GOSUB 180
1294 NEXT Z1
1320 GOSUB 180:GOTO 130
1330 END 
4000 GOSUB 870:GOTO 540
4010 GOSUB 870:GOTO 660
4020 GOSUB 870:GOTO 790
5000 LIN=LIN+1
5010 IF LIN<21 THEN RETURN 
5015 IF R9=R0 THEN LIN=6:RETURN 
5020 GOSUB 180
5030 IF R9=R0 THEN LIN=6:RETURN 
5035 GOSUB 5600
5040 RETURN 
5600 GOSUB 140
5605 ? "}":? " FOR A MORTGAGE OF  $";Z(Z1)
5610 ? " __________________________________"
5620 ? :? " RATE   YEARS  PAYMENTS    INTEREST "
5630 ? :LIN=5
5640 RETURN 
7000 POSITION 3,18:? "ретурн, with no data, will                  terminate data group."
7010 RETURN 
9000 ? "   MORTGAGE COMPARISON PROGRAM":? :? 
9020 ? "This program provides a comparison":? :? "of different mortgage terms.":? :? :? 
9030 ? "The program will display the":? :? "monthly payments and total interest":? 
9040 ? "for all possible combinations of":? :? "mortgage amounts, interest rates,":? 
9045 ? "and mortgage lives.":GOSUB 180
9050 ? "The mortgage amounts are input in":? :? "dollars, the interest rates in":? 
9060 ? "percents, and the mortgage lives":? :? "in years.":? 
9110 ? :? :? :? "It is a modification of MORTCOST":? :? "      By  J.E. Felch"
9120 ? :? "  Amos Tuck School of Business"
9130 GOSUB 180:? "The program will ask for the input":? :? "values one at a time.":? :? 
9140 ? "One to ten values may be entered":? :? "for each category. When all values":? 
9150 ? "for a category have been entered,":? :? "press ретурн without entering any":? 
9160 ? "numbers. The program will move to":? :? "the next category, or begin the":? :? "calculations."
9170 GOSUB 180:? "Each mortgage amount will occupy":? :? "a single display.":? :? 
9180 ? "If all combinations cannot be":? :? "shown on a single screen, they will":? 
9190 ? "be displayed one screen at a time":? :? "until all have been shown."
9210 GOSUB 180:? :? "When all calculation values have":? 
9215 ? "been displayed, the program will":? 
9220 ? "ask if you wish to consider another":? :? "set of terms.  If the response is":? 
9230 ? "ы or ыес, it will return to the":? :? "beginning of the program."
9240 GOSUB 180:RETURN 
