--- title: "Interest" id: 57274 type: "computer_media" slug: "interest" url: "http://localhost/computer_media/interest/" markdown_url: "http://localhost/computer_media/interest.md" published_at: "2024-10-04T07:57:48+00:00" modified_at: "2026-03-30T21:18:45+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2024/10/162_Intr.png" excerpt: "A monthly savings calculator that compounds interest step by step, then breaks down total value, total invested, and net interest earned." 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/" media_contents: - id: 56734 title: "Timex Sinclair Public Domain Library Tape 1003" type: "computer_media" url: "http://localhost/computer_media/timex-sinclair-public-domain-library-tape-1003/" media_type: "Program" mediadate: "198x" images: - url: "http://localhost/wp-content/uploads/2024/10/162_Intr.png" media_type_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 | Variable | Role | | --- | --- | | `A` | Running balance (initially the lump sum, updated each month) | | `B` | Monthly deposit amount | | `I` | Monthly interest multiplier (reused from annual rate input) | | `T` | Duration in years (input), then overwritten with total months | | `C` | Loop counter (months elapsed) | | `D` | Snapshot 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. ## 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 ```