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 with PRINT immediately after entry — a common ZX81/TS1000 idiom since INPUT does not display the entered value on its own line in all contexts. The computed pay is displayed in a formatted sentence alongside the input values. The program halts with STOP at line 60, while lines 70 and 80 (SAVE and RUN) are utility lines appended after the main logic.
Program Analysis
Program Structure
The program is organised into three logical phases: input collection (lines 10–22), calculation (line 30), and output (lines 40–50), followed by a STOP at line 60. Lines 70 and 80 are utility lines outside the main execution path.
- Lines 10–22: Prompt for and read hours worked (
H) and hourly rate (R), echoing each with a PRINT after INPUT. - Line 30: Computes gross pay as
P = H * R. - Lines 40–50: Print a formatted summary message including
H,R, andP. - Line 60: STOP halts execution cleanly.
Key BASIC Idioms
The pattern of following each INPUT with an immediate PRINT of the same variable (lines 11–12 and 21–22) is a well-known ZX81/TS1000 idiom. On this platform, INPUT does not automatically reprint the accepted value in the normal display area after the input line is processed, so the explicit PRINT serves as confirmation to the user.
Output Formatting
Lines 40 and 50 use semicolon-separated expressions within PRINT to interleave string literals with numeric variables, producing a readable sentence-style output. The dollar sign is embedded as a literal string character since there is no currency-formatting function in this BASIC dialect.
| Line | Variable(s) Used | Purpose |
|---|---|---|
| 11 | H | Input: hours worked |
| 21 | R | Input: hourly rate |
| 30 | P | Compute gross pay |
| 40–50 | H, R, P | Display formatted result |
Notable Observations
- No input validation is performed; negative or zero values for
HorRwould produce mathematically valid but nonsensical results. - The output on line 50 appends a literal period and space before “THANK YOU-” within the string, indicating the decimal point is cosmetic punctuation rather than a computed value — no rounding or formatting of
Pis applied. - Line 80 (
RUN) would restart the program if reached, but it is never reached during normal execution due to theSTOPat line 60.
Content
Source Code
1 REM PAYROLL MESSAGE
10 PRINT "ENTER HOURS WORKED"
11 INPUT H
12 PRINT H
20 PRINT "ENTER RATE"
21 INPUT R
22 PRINT R
30 LET P=H*R
40 PRINT "FOR WORKING ";H;" HOURS AT $ ";R;"/HOUR"
50 PRINT "YOUR PAY IS $ ";P;". THANK YOU-"
60 STOP
70 SAVE "1012%7"
80 RUN
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.
