--- title: "PayCalc" id: 57238 type: "computer_media" slug: "paycalc" url: "http://localhost/computer_media/paycalc/" markdown_url: "http://localhost/computer_media/paycalc.md" published_at: "2024-10-04T07:05:34+00:00" modified_at: "2026-03-30T21:19:08+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2024/10/128_PayC.png" excerpt: "A straightforward pay calculator prompts for hours and rate, then displays a formatted wage summary — hiding a few curious structural details worth a closer look." 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: "Finance" slug: "finance" taxonomy: "genre" url: "http://localhost/type/finance/" 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/128_PayC.png" media_type_tags: "Finance" --- # PayCalc This program calculates gross pay by multiplying hours worked by an hourly rate. It prompts the user to enter hours and rate via INPUT statements, echoing each value back immediately after entry, then computes the product and displays a formatted summary. The STOP at line 70 halts execution before the SAVE and RUN lines at 80–90, which serve as utility lines outside the normal execution path. The immediate PRINT of each INPUT value (lines 12 and 22) is a common technique to confirm entry on screen before proceeding. *** ## Program Analysis ### Program Structure The program is divided into three logical phases, separated by line-number groupings in tens: 1. **Input phase (lines 10–22):** Prompts for and accepts hours (`H`) and rate (`R`), printing each value back immediately after entry. 2. **Calculation and output phase (lines 30–60):** Computes pay as `P = H * R` and prints a three-line summary. 3. **Utility lines (lines 70–90):**`STOP` halts normal execution; `SAVE` and `RUN` at lines 80–90 are accessible only by direct `GO TO` or manual execution. ### Key BASIC Idioms - **Echo-after-input:** Lines 12 and 22 immediately `PRINT` the just-entered values `H` and `R`. This was a common pattern to visually confirm input, since the INPUT prompt line is cleared after entry on some implementations. - **Single-letter variables:**`H`, `R`, and `P` are used throughout, keeping the program compact. - **STOP before SAVE/RUN:** Placing `STOP` at line 70 prevents the `SAVE` and `RUN` lines from executing during normal program flow, a standard housekeeping technique. ### Variable Summary | Variable | Purpose | | --- | --- | | `H` | Hours worked (user input) | | `R` | Hourly rate (user input) | | `P` | Gross pay (`H * R`) | ### Notable Techniques and Anomalies - The REM at line 5 serves purely as a program title label (`PAYCALC`) and has no effect on execution. - No input validation is present; negative or zero values for hours or rate will produce mathematically correct but practically nonsensical results without any error message. - Currency formatting is handled entirely by string literals (`"PAY IS $ "`), with no attempt to format the numeric output to two decimal places, so results may display with varying numbers of digits after the decimal point. - Line 90 (`RUN`) would restart the program from the beginning if reached, but is unreachable in normal execution due to the `STOP` at line 70. ## Source Code ``` 5 REM PAYCALC 10 PRINT "ENTER HOURS" 11 INPUT H 12 PRINT H 20 PRINT "ENTER RATE" 21 INPUT R 22 PRINT R 30 LET P=H*R 40 PRINT "HOURS WORKED ARE ";H 50 PRINT "HOURLY RATE IS $ ";R 60 PRINT "PAY IS $ ";P 70 STOP 80 SAVE "1012%8" 90 RUN ```