--- title: "Payroll" id: 57236 type: "computer_media" slug: "payroll-2" url: "http://localhost/computer_media/payroll-2/" markdown_url: "http://localhost/computer_media/payroll-2.md" published_at: "2024-10-04T06:59:24+00:00" modified_at: "2026-03-30T21:19:09+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2024/10/126_PayR.png" excerpt: "A simple payroll calculator that applies hourly and time-and-a-half overtime rates, looping until a negative sentinel value signals the end of input." 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/" - 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/126_PayR.png" media_type_tags: "Business, Finance" --- This program calculates an employee’s gross pay based on hours worked, applying a standard overtime rule. For up to 40 hours, pay is computed at a flat rate of $7 per hour. Hours beyond 40 are paid at time-and-a-half ($10.50/hour). Entering a negative value for hours terminates the program via STOP at line 70. The program loops continuously via line 65, prompting for successive payroll entries until a negative sentinel value is entered. *** ## Program Analysis ### Program Structure The program is a short, self-contained loop with a single input/output cycle. It prompts for hours worked, branches based on the value entered, computes pay, prints the result, and repeats. A negative input value serves as a sentinel to exit the loop. 1. **Lines 10–12:** Prompt, accept, and echo the hours value. 2. **Lines 15–20:** Two conditional branches — exit on negative input, jump to overtime calculation if hours exceed 40. 3. **Lines 30–40:** Standard-time pay calculation (`P = 7 * H`), then skip to output. 4. **Line 50:** Overtime pay calculation with time-and-a-half for hours over 40. 5. **Lines 60–65:** Print result and loop back to line 10. 6. **Line 70:** STOP — reached only by negative input sentinel. ### Pay Calculation Logic The base rate is $7.00/hour. The two pay formulas used are: | Condition | Formula | Line | | --- | --- | --- | | H ≤ 40 | `P = 7 * H` | 30 | | H > 40 | `P = 7 * 40 + 1.5 * 7 * (H - 40)` | 50 | The overtime formula correctly pays the first 40 hours at the base rate and applies a 1.5× multiplier only to the excess hours. This is a textbook application of a piecewise pay function. ### Key BASIC Idioms - **Sentinel value:** A negative hours value (line 15) is used to signal end-of-data and branch to `STOP`, a common idiom when `EOF` detection is unavailable. - **Unconditional loop:**`GOTO 10` at line 65 creates an infinite loop, relying entirely on the sentinel to exit — there is no FOR/NEXT or conditional loop structure. - **Echo of input:** Line 12 prints `H` immediately after input, providing visual confirmation of the entered value before processing. ### Anomalies and Minor Issues - **Zero hours:** An input of `H = 0` is valid and will correctly return a pay of $0, though it may not be meaningful in practice. - **No input validation beyond sign check:** Fractional or very large hour values are accepted without further bounds checking. - **Line 90 (`RUN`):** A `RUN` statement following a `SAVE` is a common idiom to restart execution after saving, but since `SAVE` is on line 80 and `STOP` is on line 70, normal program flow never reaches line 80 — these lines are only reachable if the user manually runs them or if execution falls through in an unusual way. ## Source Code ``` 1 REM PAYROLL 10 PRINT "ENTER HOURS WORKED" 11 INPUT H 12 PRINT H 15 IF H<0 THEN GOTO 70 20 IF H>40 THEN GOTO 50 30 LET P=7*H 40 GOTO 60 50 LET P=7*40+1.5*7*(H-40) 60 PRINT "PAY IS:$ ";P 65 GOTO 10 70 STOP 80 SAVE "1012%6" 90 RUN ```