--- title: "Car Payment" id: 57010 type: "computer_media" slug: "car-payment" url: "http://localhost/computer_media/car-payment/" markdown_url: "http://localhost/computer_media/car-payment.md" published_at: "2024-10-02T07:34:20+00:00" modified_at: "2026-03-30T21:20:13+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2024/10/34_Car.png" excerpt: "A car loan payment calculator using the amortisation formula — spot the typo that breaks the interest rate conversion before it runs." 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 1000" slug: "ts1000" taxonomy: "post_tag" url: "http://localhost/tag/ts1000/" model: - name: "Timex/Sinclair 1000" slug: "ts-1000" taxonomy: "model" url: "http://localhost/model/ts-1000/" genre: - name: "Finance" slug: "finance" taxonomy: "genre" url: "http://localhost/type/finance/" - name: "Home" slug: "home" taxonomy: "genre" url: "http://localhost/type/home/" media_contents: - id: 56732 title: "Timex Sinclair Public Domain Library Tape 1001" type: "computer_media" url: "http://localhost/computer_media/timex-sinclair-public-domain-library-tape-1001/" media_type: "Program" mediadate: "198x" images: - url: "http://localhost/wp-content/uploads/2024/10/34_Car.png" media_type_tags: "Finance, Home" --- # Car Payment This program calculates monthly car loan payments using the standard amortisation formula. It prompts the user for purchase price, down payment, loan term in months, and annual interest rate, then computes the monthly payment rounded to the nearest cent. The interest rate conversion at line 210 contains a notable typo: `0.0$` should be `0.01`, meaning the division by 100 to convert the percentage to a decimal is broken as written. The program loops continuously, allowing recalculation by pressing any key after displaying the result. *** ## Program Analysis ### Program Structure The program is organised into a simple sequential flow with a loop back to the start for repeated calculations: 1. Lines 5–60: Title banner with a decorative row of asterisks 2. Lines 100–201: Four `INPUT` prompts collecting purchase price (`T`), down payment (`R`), number of months (`N`), and annual interest rate (`I`) 3. Lines 210–260: Interest conversion, amortisation calculation, rounding, and display 4. Lines 300–320: Keypress wait loop and restart via `GOTO 20` 5. Lines 400–500: `SAVE` with auto-run flag and `RUN` sentinel ### The Amortisation Formula Line 230 implements the standard fixed-rate loan payment formula: `P = (T - R) * I / (1 - 1 / (1 + I) ** N)` where `T - R` is the principal (purchase price minus down payment), `I` is the monthly interest rate, and `N` is the number of months. The `**` operator is used for exponentiation, which is standard BASIC syntax here. ### Key Bug: Broken Interest Conversion Line 210 reads: `LET I=(0.0$*I)/12` The token `0.0$` is clearly a typo for `0.01`, the multiplier needed to convert an annual percentage (e.g. 12) to a decimal (0.12) before dividing by 12 to obtain the monthly rate. As written, this line would cause a syntax error at runtime. The correct form should be: `LET I=(0.01*I)/12` ### Notable Techniques - **Echo-printing inputs:** Lines 111, 141, 171, and 201 each `PRINT` the just-entered value immediately after `INPUT`. On ZX81/TS1000 hardware, `INPUT` erases its own prompt line on acceptance, so reprinting confirms the value entered. - **Penny rounding:** Line 240 uses `INT(100*P+0.5)/100` to round the payment to the nearest cent — a common fixed-point rounding idiom in BASIC. - **Keypress polling loop:** Lines 310–320 use `IF INKEY$="" THEN GOTO 310` to spin-wait for any key before restarting, a typical ZX81 idiom. - **Asterisk separator:** Lines 30–50 use a `FOR` loop to print 11 asterisks as a decorative divider, avoiding a long literal string. ### Variable Summary | Variable | Purpose | | --- | --- | | `T` | Total purchase price | | `R` | Down payment (deposit) | | `N` | Number of monthly payments | | `I` | Annual interest rate (input), then converted to monthly decimal rate | | `P` | Computed monthly payment amount | | `L` | `FOR` loop counter for asterisk banner | ### Anomalies and Notes - The `REM` at line 5 contains the program title in inverse video characters, a common technique for making the listing title stand out. - The initial `LET P=0` at line 10 is unnecessary since `P` is always assigned at line 230 before use, but it is harmless. - The `SAVE "1003%4"` at line 400 uses an inverse `4` character as an auto-run flag encoding the starting line number. ## Source Code ``` 5 REM %C%A%R% %P%A%Y%M%E%N%T%S 10 LET P=0 20 PRINT "CAR PAYMENT" 30 FOR L=1 TO 11 40 PRINT "*"; 50 NEXT L 60 PRINT 100 PRINT "PURCHASE PRICE?" 110 INPUT T 111 PRINT T 130 PRINT "DOWN PAYMENT?" 140 INPUT R 141 PRINT R 160 PRINT "NUMBER OF MONTHS?" 170 INPUT N 171 PRINT N 190 PRINT "ANNUAL INTEREST?" 200 INPUT I 201 PRINT I 210 LET I=(0.0$*I)/12 220 CLS 230 LET P=(T-R)*I/(1-1/(1+I)**N) 240 LET P=INT (100*P+.5)/100 250 PRINT "PAYMENT WILL BE" 260 PRINT "$";P;" A MONTH" 300 PRINT "FOR MORE,PRESS ANY KEY" 310 IF INKEY$="" THEN GOTO 310 311 PRINT 320 GOTO 20 400 SAVE "1003%4" 500 RUN ```