Car Payment

This file is part of and Timex Sinclair Public Domain Library Tape 1001. Download the collection to get this file.
Date: 198x
Type: Program
Platform(s): TS 1000
Tags: Finance, Home

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

VariablePurpose
TTotal purchase price
RDown payment (deposit)
NNumber of monthly payments
IAnnual interest rate (input), then converted to monthly decimal rate
PComputed monthly payment amount
LFOR 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.

Content

Appears On

Assembled by Tim Ward from many sources. Contains programs 10001 – 10050.

Related Products

Related Articles

Related Content

Image Gallery

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 

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

People

No people associated with this content.

Scroll to Top