5 A$="##     ###.##   #####.##        #####.##        #####.##"
6 B$="YR. ##  ####.##    ####.##
10 PRINT "MORTGAGE AMORTIZATION TABLE"
20 PRINT 
29 REM - STATEMENTS 30 TO 150 REQUEST USER INPUT
30 PRINT "REGULAR PAYMENT";
40 INPUT R
50 PRINT "TERM IN YEARS";
60 INPUT Y
70 PRINT "PRINCIPAL";
80 INPUT P
90 PRINT "ANNUAL INTEREST RATE";
100 INPUT I
109 REM - CONVERT FROM PERCENT TO DECIMAL
110 I=I/100
120 PRINT "NUMBER OF PAYMENTS PER YEAR";
130 INPUT N
140 PRINT "START PRINTING WITH WHAT YEAR";
150 INPUT X
159 REM - START PRINTING AT BEGINNING OF A YEAR
160 X=INT(X)
169 REM - INITIALIZE VARIABLES
170 C1=0
180 I2=0
190 I3=0 
200 J0=0
210 N1=N
220 K=66
230 B0=P
240 A1=0
250 A2=0
259 REM - TERM LESS THAN ONE YEAR?
260 IF INT(Y)<1 THEN 690
269 REM - LOOP FOR EACH YEAR
270 FOR J0=1 TO INT(Y)
279 REM - START PRINTING?
280 IF J0<X THEN 410
289 REM - NEED TO START NEXT PAGE?
290 IF K+N+3<58 THEN 400
299 REM - SPACE TO TOP OF NEXT PAGE (ASSUME 66 LINES PER PAGE)
300 FOR K1=K TO 66
310 PRINT 
320 NEXT K1
330 PRINT 
339 REM - PRINT PAGE HEADINGS
340 PRINT "                    MORTGAGE AMORTIZATION TABLE"
350 PRINT "      PRINCIPAL $";P;"     AT";I*100;"%     FOR";Y; "YEARS"
360 PRINT "                     REGULAR PAYMENT = $";R
370 PRINT
380 PRINT "NO     ";"INTEREST","AMORTIZED","BALANCE","ACCUM INTEREST"
389 REM - COUNT LINES PRINTED ON EACH PAGE IN K
390 K=7
400 K=K+N+3
410 FOR J1=1 TO N1
419 REM - CALCULATE INTEREST PAID THIS PAYMENT, ROUND OFF
420 I1=INT((B0*I/N)*100+.5)/100
429 REM - COUNT NUMBER OF PAYMENTS MADE SO FAR
430 C1=C1+1
439 REM - CALCULATE AMOUNT AMORTIZED THIS PAYMENT 
440 A=R-I1
449 REM - SUM AMOUNT AMORTIZED TO DATE
450 A1=A1+A
459 REM - CALCULATE BALANCE DUE
460 B0=P-A1
468 REM - LAST PAYMENT? IF YES, CALCULATE AMOUNT SO THAT THE 
469 REM - BALANCE DUE EQUALS $00.00 AFTER THIS PAYMENT 
470 IF C1<>N*Y THEN 520
480 R=R+B0
490 A=A+B0
500 A1=A1+B0
510 B0=0
519 REM - SUM INTEREST PAID TO DATE
520 I2=I2+I1
529 REM - SUM INTEREST PAID THIS YEAR
530 I3=I3+I1
539 REM - SUM AMOUNT AMORTIZED THIS YEAR
540 A2=A2+A
549 REM - STARTED PRINTING? IF YES, PRINT COMPUTED VALUES IN TABLE
550 IF J0<X THEN 570
560 PRINT USING A$;J1,I1,A,B0,I2
570 NEXT J1
579 REM - LAST PAYMENT? IF YES, ROUND OFF, PRINT 
580 IF C1<>N*Y THEN 600
590 PRINT  "       LAST PAYMENT = $";(INT(R*100+.5))/100
599 REM - STARTED PRINTING? IF YES, PRINT VEARLY TOTALS
600 IF J0<X THEN 640
610 PRINT 
620 PRINT USING B$;J0,I3,A2
630 PRINT 
632 I3=0
635 A2=0
639 REM - COMPLETED TERM?
640 IF J0>Y THEN 720
649 REM - REINITIALIZE YEARLY VARIABLES
670 NEXT J0
679 REM - NEED TO PRINT A PARTIAL YEAR?
680 IF Y=J0 THEN 720 
689 REM - ADJUST VARIABLES TO PRINT A PARTIAL YEAR
690 N1=((Y-INT(Y))*12)/12*N
700 J1=J1+1
710 GOTO 280
720 PRINT 
729 REM - RESTART OR END PROGRAM?
730 PRINT "CHANGE DATA AND RECOMPUTE? (1=YES, 0=NO)";
740 INPUT Z
750 IF Z=1 THEN 20
760 END
