This program calculates depreciation schedules and income taxes for a capital asset, comparing two depreciation methods side by side: Straight-Line (SL) and Sum-of-Years-Digits (SOYD). The user inputs sales, cost of goods sold, operating expenses, asset cost, scrap value, and asset life; the program then iterates year by year, decrementing the remaining life counter and recomputing SOYD depreciation each pass. Income tax is computed via a subroutine at line 411 using a bracketed marginal-rate table with five bands (17%, 20%, 30%, 40%, and 46%), consistent with late-1970s/early-1980s US corporate tax schedules. Results are printed in a two-column tabular format for each year until the asset life reaches 1, at which point the program halts.
Program Analysis
Program Structure
The program is organised into three logical phases: input collection (lines 5–48), per-year computation and output (lines 70–410), and a shared tax subroutine (lines 411–424). A single GOTO 90 at line 410 forms the main loop, re-entering at the SOYD depreciation calculation after decrementing N, so the loop body spans lines 90–410. The loop terminates via the IF N=1 THEN GOTO 430 guard at line 390, which branches to STOP.
Depreciation Calculations
Two methods are computed in parallel each year:
- Straight-Line (SL):
F = INT((E-S)/N)at line 70, whereEis asset cost,Sscrap value, andNthe original life — but note thatNis decremented each iteration (line 400), so from year 2 onward the divisor shrinks and the SL figure is recalculated incorrectly. A correct implementation would preserve the original life in a separate variable. - Sum-of-Years-Digits (SOYD):
G = (N²+N)/2at line 80 (the sum of digits 1…N), thenH = INT(N/G*(E-S))at line 90. BecauseNis the remaining life each pass, this is the standard SOYD formula and behaves correctly.
Tax Subroutine
The subroutine at lines 411–424 implements a five-bracket marginal tax schedule. The caller stores the taxable income in T and reads the result from T1. The brackets are:
| Income range | Base tax | Marginal rate |
|---|---|---|
| ≤ $25,000 | $0 | 17% |
| $25,001–$50,000 | $4,250 | 20% |
| $50,001–$75,000 | $9,250 | 30% |
| $75,001–$100,000 | $16,750 | 40% |
| > $100,000 | $26,750 | 46% |
This schedule closely matches US corporate income tax rates in effect circa 1978–1981. The subroutine is called twice per year (lines 112 and 115) with the SL and SOYD taxable incomes respectively, using the variable T as both input and working storage.
Key BASIC Idioms
- The
**operator (line 80) is used for exponentiation to computeN², standard on ZX81/TS1000 BASIC. INT()is applied throughout to truncate fractional currency values to whole dollars.- The echo-print pattern (
INPUT Xfollowed immediately byPRINT X) is used for all inputs (lines 15–16, 25–26, etc.) to confirm entries on the display, a common ZX81 idiom sinceINPUTdoes not leave the value visible after entry. - A
GOSUB/subroutine pattern (lines 112, 115 → 411–424) avoids duplicating the tax bracket logic.
Notable Bugs and Anomalies
- SL depreciation divisor error: Line 70 uses the current (decremented) value of
Nrather than the original asset life. From year 2 onward,Fwill be larger than the correct annual SL charge, overstating depreciation and understating income. - Uninitialised
Z: The year counterZis never explicitly set to zero; it relies on the system initialising numeric variables to 0, which ZX81 BASIC does, so this works in practice. - Dead code at lines 126 and 140:
GOTO 140at line 126 jumps to line 140, which is the very next executed line anyway; theGOTOis redundant. This suggests the program was edited and some intervening lines were removed. - Net income calculation uses residual
T: Line 140 computesM = T - K, but at this pointTholdsJ(the SOYD taxable income) from the second subroutine call, notI. The correct SL net income should beI - K; usingTinstead producesJ - K, mixing SOYD income with SL tax.
Content
Source Code
5 REM DEPRECIATION AND INCOME TAXES(DEPTAX)
6 PRINT TAB (2);"DEPRECIATION AND INCOME TAXES"
7 PRINT
10 PRINT "ENTER SALES"
15 INPUT A
16 PRINT A
20 PRINT "ENTER COST OF GOODS SOLD,EXCEPT DEPRECIATION"
25 INPUT B
26 PRINT B
30 LET C=A-B
31 PRINT "ENTER OPER.EXP."
32 INPUT D
33 PRINT D
40 PRINT "ENTER COST"
41 INPUT E
42 PRINT E
43 PRINT "ENTER SCRAP"
44 INPUT S
45 PRINT S
46 PRINT "ENTER LIFE OF ASSET"
47 INPUT N
48 PRINT N
70 LET F=INT ((E-S)/N)
80 LET G=(N**2+N)/2
90 LET H=INT (N/G*(E-S))
100 LET I=C-(D+F)
110 LET J=C-(D+H)
111 LET T=I
112 GOSUB 411
113 LET K=T1
114 LET T=J
115 GOSUB 411
116 LET L=T1
126 GOTO 140
140 LET M=T-K
150 LET O=J-L
160 LET Z=Z+1
170 PRINT
190 PRINT "YEAR";Z
300 PRINT ,"ST.LINE","SOYD"
310 PRINT "NET SALES",A,A
320 PRINT "CGS",B,B
330 PRINT "GROSS PROFIT",C,C
340 PRINT "OPER.EXP.",D,D
350 PRINT "DEPRECIATION",F,H
360 PRINT "INC.BEF.TAX",I,J
370 PRINT "INCOME TAX",K,L
380 PRINT "NET INCOME",M,O
390 IF N=1 THEN GOTO 430
400 LET N=N-1
410 GOTO 90
411 IF T>100000 THEN GOTO 417
412 IF T>75000 THEN GOTO 419
413 IF T>50000 THEN GOTO 421
414 IF T>25000 THEN GOTO 423
415 LET T1=INT (.17*T)
416 GOTO 424
417 LET T1=26750+INT (.46*(T-100000))
418 GOTO 424
419 LET T1=16750+INT (.40*(T-75000))
420 GOTO 424
421 LET T1=9250+INT (.30*(T-50000))
422 GOTO 424
423 LET T1=4250+INT (.20*(T-25000))
424 RETURN
430 STOP
440 SAVE "1012%0"
450 RUN
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.
