--- title: "Sales Tax Calculation" id: 57234 type: "computer_media" slug: "sales-tax-calculation" url: "http://localhost/computer_media/sales-tax-calculation/" markdown_url: "http://localhost/computer_media/sales-tax-calculation.md" published_at: "2024-10-04T06:57:31+00:00" modified_at: "2026-03-30T21:19:10+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2024/10/124_STax.png" excerpt: "A compact sales tax calculator with a 5.25% fixed rate loops for multiple transactions and displays itemised cost, tax, and total for each sale." 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: "Business" slug: "business" taxonomy: "genre" url: "http://localhost/type/business/" 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/124_STax.png" media_type_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 | Variable | Purpose | | --- | --- | | `S` | Input sale cost entered by the user | | `T` | Fixed tax rate (0.0525 = 5.25%) | | `X` | Calculated tax amount (S × T) | | `F` | Final 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. ## 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 ```