Mortgage Comparison Program

Date: 198x
Type: Program
Platform(s): TS 2068
Tags: Finance

Compares mortgages by printing a table of the monthly principal-and-interest payment and the total interest paid. You choose which figure varies: the loan amount, the interest rate or the number of years. You then give the range and the step, along with the two fixed values, and the program prints one row per step. Rates can be typed as a percentage or as a decimal fraction in the amount and years modes.

No author is named in the listing. The program saves itself as “COMPARISON”.

Program Analysis

Structure

  • Lines 5–50: title and the choice of mode 1, 2 or 3.
  • Lines 70–720: variable amount. Lines 1000–1410: variable interest. Lines 2000–2340: variable years.
  • Lines 2270–2315: the shared calculation, used as a subroutine by modes 1 and 2 and as the loop body by mode 3.

The Calculation

With I the monthly rate, the payment factor is M=I/((1+I)^(Y*12)-1)+I, the standard annuity formula rearranged. The monthly payment is M*P and the total interest is the payment times the number of months, less the principal. Results are rounded to cents with INT (100*x+.5)/100.

Notable Techniques

  • One block of code at line 2270 is both a subroutine and the body of a FOR loop: IF A<>3 THEN RETURN sends modes 1 and 2 back, while mode 3 falls through to the print and NEXT Y.
  • A rate below 1 is multiplied by 100, so 0.095 and 9.5 give the same result in the amount and years modes.

Potential Issues

  • The variable-interest mode opens FOR Z twice (lines 1290 and 1330); the inner loop does all the work and the table heading is printed once, so the outer loop is redundant.
  • The variable-interest mode does not convert decimal rates, so rates must be typed as percentages there.
  • Any number other than 2 or 3 at the first prompt selects the variable-amount mode.
  • Long tables scroll and stop at the “scroll?” prompt.

This program came from an Oliger (JLO SAFE) disk and was converted to load from tape. It needed no changes apart from an autostart at line 5, and was tested in ZEsarUX.

Image Gallery

Source Code

    5 PAPER 0: BORDER 0: INK 9: CLS 
   10 PRINT "MORTGAGE COMPARISON PROGRAM"
   20 PRINT '"F0R VARIABLE AMOUNT  ENTER ""1""";'"FOR VARIABLE INTREST ENTER ""2""";'"FOR VARIABLE YEARS   ENTER ""3"""
   25 INPUT A: CLS 
   30 IF A=1 THEN GO TO 70
   40 IF A=2 THEN GO TO 1000
   50 IF A=3 THEN GO TO 2000
   70 LET S1=1: LET S2=1: LET S3=1
   80 PRINT TAB 6;"VARIABLE AMOUNT"
  100 INPUT "PRESS ANY KEY ";A$
  110 REM ENTER VARIABLE ITEMS
  130 PRINT ''"ENTER STARTING AND ENDING AMOUNT"''"TO CONSIDER"
  140 INPUT A0,A1: CLS 
  150 PRINT '"ENTER INTERVAL BETWEEN AMOUNTS,"''"I.E.1000"
  160 INPUT S1: CLS 
  340 PRINT "ENTER THE INTEREST RATE"
  350 INPUT Z: CLS 
  360 IF Z>1 THEN GO TO 380
  370 LET Z=Z*100
  380 LET R0=Z
  400 PRINT "ENTER YEARS OF MORTGAGE"
  410 INPUT Y: CLS 
  420 LET Y0=Y
  422 PRINT "START AMOUNT ";A0;'"END AMOUNT   ";A1;'"INTERVAL      ";S1;'"INT.RATE     ";Z;"%";'"YEARS        ";Y 
  530 PRINT 
  540 PRINT '"MORTGAGE";TAB 10;"MONTHLY PI";TAB 23;"TOTAL"
  550 PRINT " AMOUNT";TAB 10;" PAYMENT";TAB 23;"INTEREST"
  560 PRINT "--------";TAB 10;"--------";TAB 23;"--------"
  565 PRINT 
  570 FOR P=A0 TO A1 STEP S1
  575 GO SUB 2270
  630 PRINT P;TAB 10;INT (100*M1+.5)/100;TAB 23;INT (100*I3+.5)/100
  640 NEXT P
  650 PRINT "________________________________"
  660 PRINT 
  720 STOP 
 1000 PAPER 0: BORDER 0: INK 9: CLS 
 1020 PRINT TAB 6;"VARIABLE INTERESTS"
 1030 LET S1=1: LET S2=1: LET S3=1
 1040 INPUT "PRESS ANY KEY ";A$: CLS 
 1050 REM ENTER VARIABLE ITEMS
 1140 PRINT "ENTER LOWEST & HIGHEST INTEREST"''"RATE TO CONSIDER"
 1150 INPUT R0,R1: CLS 
 1160 PRINT '"ENTER INTERVAL BETWEEN PRINTS"''"(.25 for 1/4%)"
 1170 INPUT S2: CLS 
 1190 PRINT "ENTER THE MORTGAGE AMOUNT"
 1200 INPUT P: CLS 
 1210 LET A0=P
 1230 PRINT "ENTER YEARS OF MORTGAGE"
 1240 INPUT Y: CLS 
 1250 LET Y0=Y
 1260 PRINT "MINIMUM INTERESTS ";R0;"%";'"MAXIMUM INTEREST ";R1;"%";'"INTERVAL ";         S2;"%";'"MORTGAGE AMOUNT  ";P;'"YEARS OF MORTAGE ";Y
 1270 PRINT 
 1280 PRINT 
 1290 FOR Z=R0 TO R1 STEP S2
 1300 PRINT "INTEREST";TAB 10;"MONTHLY PI";TAB 23;"TOTAL"
 1310 PRINT " RATE";TAB 10;" PAYMENT";TAB 23;"INTEREST"
 1320 PRINT "--------";TAB 10;"--------";TAB 23;"--------"
 1330 FOR Z=R0 TO R1 STEP S2
 1335 GO SUB 2270
 1390 PRINT Z;"%";TAB 10;INT (100*M1+.5)/100;TAB 23;INT (100*I3+.5)/100
 1400 NEXT Z
 1410 STOP 
 2000 PAPER 0: BORDER 0: INK 9: CLS 
 2020 PRINT TAB 6;"VARIABLE YEARS"
 2030 LET S1=1: LET S2=1: LET S3=1
 2040 INPUT "PRESS ANY KEY ";A$: CLS 
 2050 REM ENTER VARIABLE ITEMS
 2060 PRINT "ENTER THE LOWEST AND HIGHEST"''"NUMBER OF YEARS TO CONSIDER"
 2070 INPUT Y0,Y1: CLS 
 2080 PRINT "ENTER INTERVAL BETWEEN YEARS,"''"I.E.:5 OR 10"
 2090 INPUT S3: CLS 
 2100 REM INPUT OF CONSTANT ITEMS
 2110 PRINT "ENTER THE MORTGAGE AMOUNT"
 2120 INPUT P: CLS 
 2130 LET A0=P
 2150 PRINT "ENTER THE INTEREST RATE"
 2160 INPUT Z: CLS 
 2170 PRINT "MINIMUM YEARS ";Y0;'"MAXIMUM YEARS ";Y1;'"INTERVAL      ";S3;'"MORTGAGE AMT. ";P;'"INTEREST RATE ";Z;"%"; '''
 2180 IF Z>1 THEN GO TO 2200
 2190 LET Z=Z*100
 2200 LET R0=Z
 2210 PRINT "YEARS OF";TAB 10;"MONTHLY PI";TAB 23;"TOTAL"
 2220 PRINT "MORTGAGE";TAB 10;"PAYMENT";TAB 23;"INTEREST"
 2230 PRINT "--------";TAB 10;"--------";TAB 23;"--------"
 2240 FOR Y=Y0 TO Y1 STEP S3
 2270 REM COMPUTATION AND PRINT
 2280 LET I=(Z/100)/12
 2290 LET M=I/((1+I)^(Y*12)-1)+I
 2300 LET M1=M*P
 2310 LET I3=M1*Y*12-P
 2315 IF A<>3 THEN RETURN 
 2320 PRINT Y;TAB 10;INT (100*M1+.5)/100;TAB 23;INT (100*I3+.5)/100
 2330 NEXT Y
 2340 STOP 
 9000 SAVE "COMPARISON" LINE 0

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.