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:
- Lines 5–60: Title banner with a decorative row of asterisks
- Lines 100–201: Four
INPUTprompts collecting purchase price (T), down payment (R), number of months (N), and annual interest rate (I) - Lines 210–260: Interest conversion, amortisation calculation, rounding, and display
- Lines 300–320: Keypress wait loop and restart via
GOTO 20 - Lines 400–500:
SAVEwith auto-run flag andRUNsentinel
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
PRINTthe just-entered value immediately afterINPUT. On ZX81/TS1000 hardware,INPUTerases its own prompt line on acceptance, so reprinting confirms the value entered. - Penny rounding: Line 240 uses
INT(100*P+0.5)/100to 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 310to spin-wait for any key before restarting, a typical ZX81 idiom. - Asterisk separator: Lines 30–50 use a
FORloop 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
REMat line 5 contains the program title in inverse video characters, a common technique for making the listing title stand out. - The initial
LET P=0at line 10 is unnecessary sincePis always assigned at line 230 before use, but it is harmless. - The
SAVE "1003%4"at line 400 uses an inverse4character as an auto-run flag encoding the starting line number.
Content
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.
