Hourly Wages

This file is part of Timex Sinclair Public Domain Library Tape 1001 . Download the collection to get this file.
Date: 198x
Type: Program
Platform(s): TS 1000
Tags: Business

This program calculates gross hourly wages for a single employee, handling both regular time and overtime pay. It prompts the user for an employee name, hourly pay rate, and hours worked, then branches at line 100 to apply overtime logic if hours exceed 40. Overtime hours are paid at 1.5× the regular rate, computed at line 140 as (40×P)+(T×P×1.5). Lines 175–300 are utility lines for saving and auto-running the program and are not reached during normal execution.


Program Analysis

Program Structure

The program follows a simple linear flow with a single conditional branch for overtime handling. The main execution path runs from line 10 through line 130 (or 150 via line 140 for overtime). Lines 175–300 are unreachable during normal execution and serve as housekeeping lines for saving and auto-running.

  1. Lines 10–20: Initialise accumulators T (overtime hours) and W (gross wages) to zero.
  2. Lines 23–80: Collect and echo employee name, hourly pay rate, and hours worked.
  3. Lines 90–130: Overtime check and straight-time wage calculation with STOP.
  4. Lines 140–150: Overtime wage calculation, then jumps back to line 120 to print result.
  5. Lines 175–300: Unreachable utility lines — CLEAR, SAVE, and RUN.

Wage Calculation Logic

The overtime branch is triggered when H > 40. Line 90 calculates the overtime portion as T = H - 40, and line 140 computes total wages as W = (40*P) + (T*P*1.5), correctly applying time-and-a-half only to hours beyond 40. The regular-time path at line 110 simply uses W = H*P.

ConditionFormula
H <= 40W = H * P
H > 40W = (40 * P) + ((H-40) * P * 1.5)

Key BASIC Idioms

  • Variables are explicitly initialised at lines 10–20 before use, a good practice in a language where variables default to zero but clarity aids maintenance.
  • The program echoes each INPUT value back to the screen (lines 25, 50, 80), which was common practice on systems that didn’t automatically display the entered value on a separate line.
  • The two-statement overtime test across lines 90–100 (one to calculate T, one to branch) avoids a compound IF, keeping each line simple.
  • Line 150 uses GOTO 120 to share the print and STOP at line 130 between both code paths, avoiding duplicated output code.

Notable Techniques and Anomalies

The REM statement at line 5 uses inverse-video characters spelling “HOURLY WAGES”, serving as a visually distinctive program title in the listing. The SAVE "1001%7" at line 200 saves the program under the name 1001 with an inverse 7 character as an auto-run flag. Line 300’s RUN would restart the program if somehow reached, but this is unreachable under normal flow. Line 175’s CLEAR is similarly unreachable and has no effect on execution.

There is a minor formatting inconsistency: line 30 uses "HOURLY PAY RATE = $"; with a semicolon (suppressing the newline before INPUT), while line 60 uses "NUMBER OF HOURS WORKED = "; similarly — but line 23 uses PRINT without a semicolon, leaving the INPUT prompt on the next line. This is stylistically inconsistent but not a bug.

Content

Appears On

Assembled by Tim Ward from many sources. Contains programs 10001 – 10050.

Related Products

Related Articles

Related Content

Image Gallery

Hourly Wages

Source Code

   5 REM %H%O%U%R%L%Y% %W%A%G%E%S
  10 LET T=0
  20 LET W=0
  23 PRINT "ENTER EMPLOYEE NAME"
  24 INPUT E$
  25 PRINT E$
  28 PRINT 
  30 PRINT "HOURLY PAY RATE = $";
  40 INPUT P
  50 PRINT P
  60 PRINT "NUMBER OF HOURS WORKED = ";
  70 INPUT H
  80 PRINT H
  90 IF H>40 THEN LET T=H-40
 100 IF H>40 THEN GOTO 140
 110 LET W=H*P
 120 PRINT "GROSS WAGES = $ ";W
 130 STOP 
 140 LET W=(40*P)+(T*P*1.5)
 150 GOTO 120
 175 CLEAR 
 200 SAVE "1001%7"
 300 RUN 

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.

People

No people associated with this content.

Scroll to Top