This program calculates compound interest under four different compounding periods — daily (360-day basis), monthly, quarterly, and annually — for a given principal, interest rate, and time in years. The user enters the principal, rate (accepted as either a decimal fraction or a percentage), and term, and the program displays all four compounded amounts side by side in a tabulated row. Rounding to the nearest cent is achieved with the idiom INT(X*100+.5)/100. After each calculation the program offers a loop-back option, allowing multiple scenarios to be compared in sequence.
Program Analysis
Program Structure
The program is linear with a single user-driven loop. After collecting inputs at lines 10–61, it performs all four compound-interest calculations at lines 90–125, prints a formatted result row at line 130, and then asks whether to repeat (lines 150–170). A GOTO 8 at line 170 returns to just after the title REM, reprinting a blank line before prompting for new inputs.
- Lines 5–8: Title REM and initial blank line
- Lines 10–61: Input principal, rate, and time with echo-prints
- Lines 70–80: Print column header row
- Lines 90–125: Compute daily, monthly, quarterly, and annual totals
- Line 130: Print results in tabulated form
- Lines 150–170: Loop or stop
Interest Rate Normalisation
Lines 42–44 provide automatic rate handling: if the entered value is ≥ 1 it is assumed to be a percentage and is divided by 100 (LET R=R/100); values already less than 1 are treated as decimal fractions and passed through unchanged. This makes the program tolerant of both input conventions without requiring the user to pre-convert.
Compound Interest Formulae
All four calculations use the standard compound-interest formula A = P(1 + r/n)^(n·t), with n varying by compounding period:
| Variable | Period | n value | Lines |
|---|---|---|---|
D | Daily | 360 | 90–95 |
M | Monthly | 12 | 100–105 |
Q | Quarterly | 4 | 110–115 |
A | Annual | 1 | 120–125 |
Note that daily compounding uses a 360-day banking year rather than 365, which is standard in many financial contexts but will yield slightly different results from an exact-day calculation.
Rounding Technique
Each result is immediately rounded to two decimal places using INT(X*100+.5)/100. The +.5 before truncation implements conventional “round half up” behaviour. This is applied to each variable individually (lines 95, 105, 115, 125) rather than at print time, so the stored values are already currency-precise.
Output Formatting
The header at line 80 uses a series of TAB calls to align seven abbreviated column labels: PRN (principal), P/C (percent), YRS (years), DLY (daily), MTH (monthly), QTL (quarterly), and ANN (annual). Line 130 prints the corresponding data values; the first three fields use explicit TAB positions while the four computed results are separated by commas, relying on the system’s default print zones. This mixed approach can cause minor alignment drift between the header and data rows depending on the width of the printed numbers.
Notable Idioms and Anomalies
- Echo-printing of inputs (lines 21, 41, 61) after each
INPUTis a common idiom to confirm what was entered on screen. - The
STOPat line 180 is followed bySAVEandLISTcommands at lines 190–200, which are utility lines for the developer and are never reached during normal program execution. - The column header uses
TAB(1)rather thanTAB(0), leaving column zero unused; the data line similarly starts atTAB(1), keeping them consistent. - The loop target
GOTO 8(line 170) jumps to the blank-line PRINT rather than to line 10, ensuring a visual separator appears between successive runs without duplicating the setup code.
Content
Source Code
5 REM %C%O%M%P%O%U%N%D% %I%N%T%E%R%E%S%T
8 PRINT
10 PRINT "ENTER PRINCIPAL"
20 INPUT P
21 PRINT P
30 PRINT "ENTER RATE"
40 INPUT R
41 PRINT R
42 IF R<1 THEN GOTO 50
44 LET R=R/100
50 PRINT "ENTER TIME IN YEARS"
60 INPUT T
61 PRINT T
70 PRINT
80 PRINT TAB (1);"PRN";TAB (6);"P/C";TAB (10);"YRS";TAB (15);"DLY";TAB (21);"MTH";TAB (25);"QTL";TAB (29);"ANN"
90 LET D=P*(1+R/360)**(360*T)
95 LET D=INT (D*100+.5)/100
100 LET M=P*(1+R/12)**(12*T)
105 LET M=INT (M*100+.5)/100
110 LET Q=P*(1+R/4)**(4*T)
115 LET Q=INT (Q*100+.5)/100
120 LET A=P*(1+R)**T
125 LET A=INT (A*100+.5)/100
130 PRINT TAB (1);P;TAB (7);R*100;TAB (11);T;D,M,Q,A
140 PRINT
150 PRINT "WANT ANOTHER? ENTER Y OR N"
160 INPUT Z$
170 IF Z$="Y" THEN GOTO 8
180 STOP
190 SAVE "1011%2"
200 LIST
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.
