Financial Ratios

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

This program is a financial ratio calculator that collects up to 23 accounting inputs (sales, cost of goods sold, net income, assets, liabilities, equity, and share data) via sequential INPUT statements and then computes 18 standard financial ratios. Ratios calculated include working capital, current ratio, acid test, accounts receivable and inventory turnover, gross profit rate, return on assets and equity, leverage ratios, book value, earnings per share, and price-to-earnings ratio. Rounding is handled throughout using the classic INT(x * scale + 0.5) / scale idiom rather than any built-in rounding function. Results are printed in a columnar layout using TAB(25) alignment for the values alongside TAB(1) labels on the left.


Program Analysis

Program Structure

The program is divided into four logical phases, separated by REM statements:

  1. Header (lines 1–3): Title display.
  2. Data entry (lines 10–242): Sequential PRINT/INPUT/PRINT triplets collect 23 values.
  3. Calculations (lines 250–420): All 18 ratios are computed and stored in lettered variables (A1Q1).
  4. Output (lines 500–800): Results printed in a two-column layout; program halts at STOP.

Input Variables

VariableMeaning
A$Date string
BSales
CCost of goods sold
DNet income
ECash
FAccounts receivable (current year-end)
GAccounts receivable (prior year-end)
HInventory (current year-end)
IInventory (prior year-end)
JOther current assets
KLand/buildings/equipment (gross)
LAccumulated depreciation
MOther assets
NTotal assets (prior year-end)
OCurrent liabilities
PLong-term debt
QOther liabilities
RPreferred stock
SCommon stock
TRetained earnings
UStockholders’ equity (prior year-end)
VMarket value of common stock
WShares of common stock outstanding
XPreferred stock dividends

Computed Ratios

VariableRatioFormula summary
A1Working capitalE+F+H+J−O
B1Current ratio(E+F+H+J)/O, 2 d.p.
C1Acid test(E+F)/O, 2 d.p.
D1A/R turnoverB / avg(F,G), 1 d.p.
E1Avg days sales in A/RF / (B/300), integer
F1Inventory turnoverC / avg(H,I), 1 d.p.
G1Days sales in inventoryH / (C/300), integer
H1Gross profit rate (%)(B−C)/B × 100, 1 d.p.
I1Net profit : avg assets (%)D / avg total assets × 100, 1 d.p.
J1Net profit : net worth (%)D / avg equity × 100, 1 d.p.
K1Net worth : liabilities(R+S+T)/(O+P+Q), 2 d.p.
L1Fixed assets : long-term debt(K−L)/P, 2 d.p.
M1Net worth : fixed assets(R+S+T)/(K−L), 2 d.p.
N1Fixed assets depreciated (%)L/K × 100, integer
O1Book value per share(S+T)/W, 2 d.p.
P1Earnings per share(D−X)/W, 2 d.p.
Q1P/E ratioV/P1, 1 d.p.

Notable Techniques

All rounding uses the classic INT(x * scale + 0.5) / scale idiom. For example, to round to two decimal places: INT(value * 100 + .5) / 100; for one decimal place the multiplier is 10; for percentage integers the division is omitted. This is the standard technique in the absence of a built-in rounding function.

The days-sales calculations at lines 300 and 320 divide by B/300 and C/300 respectively, implicitly assuming a 300-day business year (common in financial analysis) rather than 365 days.

Echo-printing each input immediately after entry (e.g. lines 22, 32, …) serves as a manual verification step, allowing the user to spot keying errors before proceeding to the next field.

Output alignment is achieved entirely with TAB(25) for all numeric results and TAB(1) for labels, producing a clean two-column display. Blank PRINT lines at lines 645, 675, 705, 735, 765, and 785 group related ratios visually.

Potential Issues and Anomalies

  • Division by zero risk: Several ratios will crash with a division-by-zero error if the user enters zero for current liabilities (O), long-term debt (P), shares outstanding (W), or if EPS (P1) resolves to zero before the P/E calculation at line 420. No error trapping is present.
  • Net worth formula inconsistency: Ratios K1, L1, and M1 define net worth as R+S+T (preferred + common + retained earnings), which excludes preferred stock from equity in some formulations — this is a common but debatable accounting convention in such programs.
  • Book value excludes preferred stock: O1 computes (S+T)/W, omitting preferred stock (R) from the numerator, giving common equity book value per share specifically rather than total equity book value.
  • Lines 810–820 are unreachable: The STOP at line 800 halts execution; lines 810 (SAVE) and 820 (RUN) can only be reached by direct command or by manually entering their line numbers.
  • Variable naming collision risk: The use of single-letter variables AW for inputs alongside two-character variables A1Q1 for results is clear in context but leaves no room for expansion without renaming.

Content

Appears On

Assembled by Tim Ward from many sources. Contains programs 10051 – 10121.

Related Products

Related Articles

Related Content

Image Gallery

Financial Ratios

Source Code

   1 REM FINANCIAL RATIO
   2 PRINT TAB (10);"FINANCIAL RATIOS"
   3 PRINT 
  10 PRINT "ENTER DATE"
  11 INPUT A$
  12 PRINT A$
  20 PRINT "ENTER SALES"
  21 INPUT B
  22 PRINT B
  30 PRINT "ENTER COST OF GOODS SOLD"
  31 INPUT C
  32 PRINT C
  40 PRINT "ENTER NET INCOME"
  41 INPUT D
  42 PRINT D
  50 PRINT "ENTER CASH"
  51 INPUT E
  52 PRINT E
  60 PRINT "ENTER AR(CURRENT Y/E)"
  61 INPUT F
  62 PRINT F
  70 PRINT "ENTER AR(PRIOR Y/E)"
  71 INPUT G
  72 PRINT G
  80 PRINT "ENTER INVENTORY(CURRENT Y/E)"
  81 INPUT H
  82 PRINT H
  90 PRINT "ENTER INVENTORY(PRIOR Y/E)"
  91 INPUT I
  92 PRINT I
 100 PRINT "ENTER OTHER CURRENT ASSETS"
 101 INPUT J
 102 PRINT J
 110 PRINT "ENTER VALUE,LAND/BLDGS/EQUIP"
 111 INPUT K
 112 PRINT K
 120 PRINT "ENTER ACCUMULATED DEPRECIATION"
 121 INPUT L
 122 PRINT L
 130 PRINT "ENTER OTHER ASSETS"
 131 INPUT M
 132 PRINT M
 140 PRINT "ENTER TOTAL ASSETS(PRIOR Y/E)"
 141 INPUT N
 142 PRINT N
 150 PRINT "ENTER CURRENT LIABILITIES"
 151 INPUT O
 152 PRINT O
 160 PRINT "ENTER LONG TERM DEBT"
 161 INPUT P
 162 PRINT P
 170 PRINT "ENTER OTHER LIABILITIES"
 171 INPUT Q
 172 PRINT Q
 180 PRINT "ENTER PREFERRED STOCK"
 181 INPUT R
 182 PRINT R
 190 PRINT "ENTER COMMON STOCK"
 191 INPUT S
 192 PRINT S
 200 PRINT "ENTER RETAINED EARNINGS"
 201 INPUT T
 202 PRINT T
 210 PRINT "ENTER STKHLDRS EQUITY(PRIOR Y/E)"
 211 INPUT U
 212 PRINT U
 220 PRINT "ENTER MARKET VALUE COMMON STOCK"
 221 INPUT V
 222 PRINT V
 230 PRINT "ENTER SHARES OF COMMON OUTSTANDING"
 231 INPUT W
 232 PRINT W
 240 PRINT "ENTER PREFERRED STOCK DIVIDENDS"
 241 INPUT X
 242 PRINT X
 250 REM CALCULATE ANSWERS
 260 LET A1=E+F+H+J-O
 270 LET B1=INT (((E+F+H+J)/O)*100+.5)/100
 280 LET C1=INT (((E+F)/O)*100+.5)/100
 290 LET D1=INT (B/((F+G)/2)*10+.5)/10
 300 LET E1=INT (F/(B/300))
 310 LET F1=INT (C/((H+I)/2)*10+.5)/10
 320 LET G1=INT (H/(C/300))
 330 LET H1=INT ((B-C)/B*1000+.5)/10
 340 LET I1=INT (D/((E+F+H+J+K-L+M+N)/2)*1000+.5)/10
 350 LET J1=INT (D/((R+S+T+U)/2)*1000+.5)/10
 360 LET K1=INT ((R+S+T)/(O+P+Q)*100+.5)/100
 370 LET L1=INT ((K-L)/P*100+.5)/100
 380 LET M1=INT ((R+S+T)/(K-L)*100+.5)/100
 390 LET N1=INT (L/K*100+.5)
 400 LET O1=INT ((S+T)/W*100+.5)/100
 410 LET P1=INT ((D-X)/W*100+.5)/100
 420 LET Q1=INT ((V/P1)*10+.5)/10
 500 REM PRINT ALL ANSWERS
 510 PRINT 
 520 PRINT 
 600 PRINT TAB (25);A$
 610 PRINT 
 620 PRINT TAB (1);"WORKING CAPITAL";TAB (25);A1
 630 PRINT TAB (1);"CURRENT RATIO";TAB (25);B1
 640 PRINT TAB (1);"ACID TEST";TAB (25);C1
 645 PRINT 
 650 PRINT TAB (1);"A/R TURN";TAB (25);D1
 660 PRINT TAB (1);"AVG.DAYS SLS IN A/R(Y/E)";TAB (25);E1
 670 PRINT TAB (1);"INV TURN";TAB (25);F1
 675 PRINT 
 680 PRINT TAB (1);"NR DAYS SLS IN INV(Y/E)";TAB (25);G1
 690 PRINT TAB (1);"GROSS PROFIT RATE";TAB (25);H1
 700 PRINT TAB (1);"NET PROFIT:AVG ASSETS";TAB (25);I1
 705 PRINT 
 710 PRINT TAB (1);"NET PROFIT:NET WORTH";TAB (25);J1
 720 PRINT TAB (1);"NET WORTH:LIAB";TAB (25);K1
 730 PRINT TAB (1);"FIXED ASSETS:L.T.D.";TAB (25);L1
 735 PRINT 
 740 PRINT TAB (1);"NET WORTH:FIXED ASSETS";TAB (25);M1
 750 PRINT TAB (1);"FIXED ASSETS DEPRCIATED";TAB (25);N1
 760 PRINT TAB (1);"BOOK VALUE";TAB (25);O1
 765 PRINT 
 770 PRINT TAB (1);"EARNINGS PER SHARE";TAB (25);P1
 780 PRINT TAB (1);"P/E RATIO";TAB (25);Q1
 785 PRINT 
 800 STOP 
 810 SAVE "1011%8"
 820 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