--- title: "Loan Compare" id: 53840 type: "computer_media" slug: "loancompar" url: "http://localhost/computer_media/loancompar/" markdown_url: "http://localhost/computer_media/loancompar.md" published_at: "2024-05-13T19:02:05+00:00" modified_at: "2026-03-30T21:43:30+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2019/02/20230809-041332.jpg" excerpt: "A handy loan payment calculator that crunches amortization math and lets you print or re-run results with a single keypress." category: - name: "Archived Media" slug: "archived-media" taxonomy: "category" url: "http://localhost/category/archived-media/" post_tag: - name: "Downloadable" slug: "downloadable" taxonomy: "post_tag" url: "http://localhost/tag/downloadable/" - name: "TS 2068" slug: "ts2068" taxonomy: "post_tag" url: "http://localhost/tag/ts2068/" model: - name: "Timex/Sinclair 2068" slug: "ts-2068" taxonomy: "model" url: "http://localhost/model/ts-2068/" indiv: - name: "John Colonna" slug: "john-colonna" taxonomy: "indiv" url: "http://localhost/indiv/john-colonna/" genre: - name: "Finance" slug: "finance" taxonomy: "genre" url: "http://localhost/type/finance/" media_contents: - id: 55361 title: "SINCUS Exchange Tape 102 – Utilities & Business" type: "computer_media" url: "http://localhost/computer_media/sincus-exchange-tape-102-utilities-business/" media_type: "Program" programmers: - name: "John Colonna" slug: "john-colonna" taxonomy: "indiv" url: "http://localhost/indiv/john-colonna/" mediadate: "1986" images: - url: "http://localhost/wp-content/uploads/2024/05/loan-compare.png" media_type_tags: "Finance" --- # Loan Compare This program calculates monthly loan payments using the standard amortization formula: monthly payment = principal × monthly_rate / (1 − (1 + monthly_rate)^−n). It accepts a loan amount, number of monthly payments, and annual interest rate as inputs, then displays both the monthly and total payment figures. Display formatting uses FOR/NEXT loops at lines 500 and 600 to draw decorative separator bars of inverse-video dollar signs and dashes across the full 32-column width. Line 9999 provides a save/verify routine that stores the program with an auto-run entry point at line 1. *** ## Program Analysis ### Program Structure The program is organized into a linear main flow (lines 5–185) with two reusable display subroutines (lines 500–650) and a standalone save routine at line 9999. Control flow is straightforward: gather three inputs, compute the monthly payment, display results, then offer a copy/repeat menu. | Line Range | Purpose | | --- | --- | | 5 | REM header with author and version | | 10–20 | Initialization: CLS, BORDER, variable reset, opening banner | | 25–110 | Input section: loan amount, number of payments, annual interest rate | | 115–160 | Calculation and results display | | 165–185 | Post-result menu: print copy or restart | | 500–550 | Subroutine: 32-character inverse-video “$” separator bar | | 600–650 | Subroutine: 32-character “-” separator bar | | 9999 | Save/verify utility | ### Amortization Formula The core calculation occupies lines 110–125. Line 110 converts the user-supplied annual percentage rate to a monthly decimal rate: `i = (0.01 * i) / 12`. Line 120 applies the standard amortization formula: `p = t * i / (1 - 1 / (1 + i) ^ n)` where `t` is the principal, `i` is the monthly rate, and `n` is the number of payments. Line 125 rounds the result to the nearest cent using the classic idiom `INT(100 * p + 0.5) / 100`. ### Display Techniques Two separator-bar subroutines use FOR/NEXT loops running exactly 32 iterations to fill the screen width. The subroutine at line 500 prints inverse-video `"$"` characters to create a highlighted border effect, while the one at line 600 prints plain `"-"` dashes. Each input value is echoed back on the screen using `INVERSE 1` with `TAB` positioning (lines 45, 75, 105), giving a form-entry feel. ### Input and Menu Handling Line 165 uses a compound `INPUT` statement with embedded `INVERSE` attributes to display a styled prompt asking the user to choose between printing a copy (`"1"`) or running again (`"2"`). Line 170 handles the LPRINT option, reconstructing the original annual rate from the stored monthly decimal by computing `i * 1200` for display. Line 175 restarts the program by jumping to line 1 (which does not exist), causing the program to terminate — this is a known idiom for a clean restart that falls through to the end. Line 180 loops back to the menu if neither valid choice is entered. ### Notable Techniques and Anomalies - Line 15 initializes `p=0` explicitly, which is unnecessary since BASIC variables default to zero, but serves as self-documentation. - The GO TO 1 at line 175 targets a non-existent line; execution stops rather than truly restarting. A correct restart would target line 10 or use `RUN`. - The LPRINT line (170) is very long, combining column headers and computed values in a single statement, relying on the printer’s 32-column (or wider) carriage width for readability. - Line 9999 is intentionally isolated and only reached manually, providing a convenient save-and-verify workflow without interfering with normal program execution. - The variable `l` is reused as the loop counter in both separator subroutines, which is safe since the subroutines are never called from within each other. ## Source Code ``` 5 REM loancompar - J. Colonna Version 1.1 Rev. 7-86 10 CLS : BORDER 6 15 LET p=0 20 GO SUB 500 25 PRINT : PRINT 30 PRINT " Enter the amount of the loan" 35 PRINT 40 INPUT t 45 PRINT TAB 14; INVERSE 1;t 50 GO SUB 600 55 PRINT 60 PRINT "Enter number of monthly payments" 65 PRINT 70 INPUT n 75 PRINT TAB 15; INVERSE 1;n 80 GO SUB 600 85 PRINT 90 PRINT " Enter the annual interest rate" 95 PRINT " (For Example - 12.5)" 100 INPUT i 105 PRINT TAB 13; INVERSE 1;i;" %" 110 LET i=(0.01*i)/12 115 PRINT 120 LET p=t*i/(1-1/(1+i)^n) 125 LET p=INT (100*p+.5)/100 130 GO SUB 500 135 PRINT : PRINT 140 PRINT "Monthly payment will be: $";p 145 PRINT 150 PRINT "Total payment will be: $";p*n 155 PRINT 160 GO SUB 500 165 INPUT INVERSE 1;"COPY(1) or AGAIN(2)?"; INVERSE 0;" ";a$ 170 IF a$="1" THEN LPRINT ; INVERSE 1;" AMT. NUMBER OF INT. MONTHLY LOAN PAYMENTS RATE PAYMENT "; INVERSE 0;"$";t;" ";n;" ";i*1200;"% $";p: LPRINT 175 IF a$="2" THEN GO TO 1 180 GO TO 165 185 STOP 500 FOR l=1 TO 32: PRINT INVERSE 1;"$";: NEXT l 550 RETURN 600 FOR l=1 TO 32: PRINT "-";: NEXT l 650 RETURN 9999 CLEAR : CLS : SAVE "loancompar" LINE 1: BEEP 1,25: PRINT "loancompar SAVED": VERIFY "": PRINT "Program VERIFIED": BEEP .5,32: BEEP .5,32 ```