PayCalc

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

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

VariablePurpose
HHours worked (user input)
RHourly rate (user input)
PGross 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.

Content

Appears On

Assembled by Tim Ward from many sources. Contains programs 10122 – 10175.

Related Products

Related Articles

Related Content

Image Gallery

PayCalc

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.

People

No people associated with this content.

Scroll to Top