Sales Tax Calculation

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: Business

This program calculates sales tax and total sale amount for a given purchase price. It applies a fixed tax rate of 5.25% (stored in variable T at line 30), computes the tax amount and final total, then prompts the user to perform another calculation or stop. The loop at line 110 returns to the input prompt if the user enters “Y”, while any input other than “N” also falls through to the STOP at line 130. The SAVE and RUN statements at lines 140–150 follow the main logic and would only execute if somehow reached past the STOP.


Program Analysis

Program Structure

The program is a straightforward single-file utility with no subroutines. It flows linearly from input through calculation to output, with a simple loop controlled by a yes/no prompt.

  1. Lines 5–8: Title display and blank line formatting.
  2. Lines 10–25: Prompt for and accept sale cost input (S), echoing the entered value.
  3. Lines 30–70: Core calculation — tax rate set, tax amount (X) computed, final total (F) derived and displayed.
  4. Lines 90–110: Loop control — accepts Q$ and branches back to line 10 if “Y”.
  5. Lines 120–130: Handles “N” with a redundant branch to STOP (line 120 jumps to 130, which is itself the next line).
  6. Lines 140–150: SAVE and RUN are unreachable during normal execution due to the STOP at line 130.

Key Variables

VariablePurpose
SInput sale cost entered by the user
TFixed tax rate (0.0525 = 5.25%)
XCalculated tax amount (S × T)
FFinal total (S + X)
Q$User’s yes/no response string

Notable Techniques and Idioms

  • The tax rate is stored in a named variable (T) rather than used as a literal in the formula, making it easy to update for different jurisdictions.
  • Line 21 echoes the entered value of S back to the screen — a common pattern to confirm input on systems where the INPUT prompt may not display the accepted value clearly.
  • Blank lines are inserted using bare PRINT statements (lines 8, 25, 65, 80) to improve output readability.

Bugs and Anomalies

  • The branch at line 120 (IF Q$="N" THEN GOTO 130) is redundant — if “N” is entered, execution would naturally fall through from line 120 to line 130 anyway. The GOTO 130 adds no functional effect.
  • If the user enters anything other than “Y” or “N” (e.g. a lowercase letter), neither branch at lines 110 nor 120 fires, and execution still reaches STOP at line 130 — which is acceptable behaviour, though unintentional.
  • The currency output uses a hard-coded dollar sign in the PRINT strings, so the tax and total values are not formatted to two decimal places; floating-point results may display with many decimal digits.

Content

Appears On

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

Related Products

Related Articles

Related Content

Image Gallery

Sales Tax Calculation

Source Code

   5 REM SALES TAX CALCULATION
   6 PRINT TAB (10);"SALES TAX CALCULATION"
   8 PRINT 
  10 PRINT "ENTER SALE COST"
  20 INPUT S
  21 PRINT S
  25 PRINT 
  30 LET T=.0525
  40 LET X=S*T
  50 PRINT "SALES TAX IS $ ";X
  60 LET F=S+X
  65 PRINT 
  70 PRINT "TOTAL SALE IS $ ";F
  80 PRINT 
  90 PRINT "WANT ANOTHER? Y/N"
 100 INPUT Q$
 101 PRINT 
 110 IF Q$="Y" THEN GOTO 10
 120 IF Q$="N" THEN GOTO 130
 130 STOP 
 140 SAVE "1012%4"
 150 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