Interest

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

This program calculates compound interest on a savings account with regular monthly deposits. The user enters an initial lump sum, a monthly deposit amount, an annual interest rate, and the investment duration in years. The loop at lines 190–220 iterates month by month, applying the compounded monthly rate to the running balance plus each deposit. At completion, it displays the total value, total amount invested, and the net interest earned. The program uses the ZX81’s FAST mode (line 150) to speed up the iterative calculation loop.


Program Analysis

Program Structure

The program is divided into three clear phases: data entry (lines 10–140), calculation (lines 150–220), and results display (lines 230–260). Input values are echoed back to the screen using PRINT AT statements, placing them at fixed column 20 on their respective rows to form a simple summary panel alongside the prompts.

Calculation Method

The interest calculation loop (lines 190–220) uses a counter variable C compared against the total number of months T (converted at line 160 by multiplying the user’s years value by 12). Each iteration adds the monthly deposit B to the current balance A, then multiplies by the monthly interest factor I, which is precomputed at line 170 as I/100/12+1. This correctly converts an annual percentage rate to a monthly multiplier and folds the “+1” in so the multiplication applies both principal growth and interest in one step.

Variable Usage

VariableRole
ARunning balance (initially the lump sum, updated each month)
BMonthly deposit amount
IMonthly interest multiplier (reused from annual rate input)
TDuration in years (input), then overwritten with total months
CLoop counter (months elapsed)
DSnapshot of the initial amount, saved before A is modified

Notable Techniques

  • FAST mode: Line 150 invokes FAST before the loop begins, suppressing the display driver to accelerate the iterative calculation — important when the loop may run hundreds of iterations for multi-year periods.
  • Variable reuse: Both A and T are repurposed after input, which saves memory but requires D to preserve the original initial amount for the final output calculations at lines 240–250.
  • Results display: TAB 20 is used in the output section to align the computed values consistently, mirroring the column-20 alignment used during data entry.

Bugs and Anomalies

  • Typo in prompt: Line 20 prints "INITIAL AMMOUNT" — “AMMOUNT” is misspelled; it should be “AMOUNT”.
  • FAST mode not cleared: The program enters FAST at line 150 but never issues a SLOW command. Output at lines 230–250 is therefore rendered in FAST mode, which on a ZX81 causes the display to blank during calculations and may produce a flickering or absent display for the results.
  • Total investment formula: Lines 240–250 compute total invested as T*B+D, using the already-converted T (months). This is correct since B is a monthly deposit and T now holds the month count, but the reuse of T makes the logic easy to misread.
  • Lines 270–280: The SAVE and RUN at lines 270–280 are utility lines for tape storage and restarting the program; they are not reached during normal execution.

Content

Appears On

Assembled by Tim Ward from many sources. Contains programs 10122 – 10175.

Related Products

Related Articles

Related Content

Image Gallery

Interest

Source Code

  10 PRINT "INTEREST"
  20 PRINT "INITIAL AMMOUNT"
  30 INPUT A
  40 PRINT AT 0,20;A
  50 PRINT "MONTHLY DEPOSIT"
  60 INPUT B
  70 PRINT AT 1,20;B 
  80 PRINT "ANNUAL INTEREST"
  90 INPUT I
 100 PRINT AT 2,20;I
 110 LET C=0
 120 PRINT "LENGTH OF TIME"
 130 INPUT T
 140 PRINT AT 3,20;T
 150 FAST 
 160 LET T=T*12
 170 LET I=I/100/12+1
 180 LET D=A
 190 IF C=T THEN GOTO 230
 200 LET A=(A+B)*I
 210 LET C=C+1
 220 GOTO 190
 230 PRINT "TOTAL VALUE";TAB 20;A
 240 PRINT "TOTAL INVESTMENT";TAB 20;T*B+D
 250 PRINT "TOTAL INTEREST";TAB 20;A-(T*B+D)
 260 STOP 
 270 SAVE "1016%2"
 280 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