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:
- Input phase (lines 10–22): Prompts for and accepts hours (
H) and rate (R), printing each value back immediately after entry. - Calculation and output phase (lines 30–60): Computes pay as
P = H * Rand prints a three-line summary. - Utility lines (lines 70–90):
STOPhalts normal execution;SAVEandRUNat lines 80–90 are accessible only by directGO TOor manual execution.
Key BASIC Idioms
- Echo-after-input: Lines 12 and 22 immediately
PRINTthe just-entered valuesHandR. 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, andPare used throughout, keeping the program compact. - STOP before SAVE/RUN: Placing
STOPat line 70 prevents theSAVEandRUNlines 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 theSTOPat line 70.
Content
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
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.
