Net Pay

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

This program calculates the required gross pay needed to achieve a desired net pay after tax and other deductions. The user inputs the desired net pay, an effective tax rate (accepted as either a decimal or a percentage, with automatic conversion at line 45–50), and any additional fixed deductions. Line 80 performs the core calculation using the formula G = INT((N+D)/(1-T)+0.5), where rounding to the nearest whole dollar is achieved by adding 0.5 before truncating with INT. The program ends with STOP at line 100, leaving the calculated gross pay displayed on screen.


Program Analysis

Program Structure

The program is short and linear, running from top to bottom in a single pass with no loops. It follows a simple input–calculate–output pattern across four logical phases:

  1. Title display (lines 8–9)
  2. User input collection (lines 10–71)
  3. Gross pay calculation (line 80)
  4. Result display and termination (lines 90–100)

Lines 110 and 120 (SAVE and LIST) are utility lines appended after the STOP at line 100 and are never reached during normal execution.

Input Echo Pattern

Each INPUT statement (lines 20, 40, 70) is immediately followed by a PRINT of the same variable (lines 21, 41, 71). This echoes the entered value back to the screen, providing a simple confirmation that the correct value was received — a common idiom in early BASIC data-entry programs where the input prompt and entered value may scroll or be ambiguous.

Tax Rate Normalisation

Lines 45–50 handle the tax rate input flexibly. If the user enters a value of 1 or greater (e.g. 25 for 25%), line 50 divides it by 100 to convert it to a decimal fraction. If the value is already less than 1 (e.g. 0.25), the branch at line 45 skips directly to line 60, leaving T unchanged. This allows both input conventions without requiring the user to know which format is expected.

Core Calculation

The gross pay formula at line 80 is:

LET G=INT((N+D)/(1.0-T)+.5)

This derives from the relationship: Net = Gross × (1 − TaxRate) − Deductions, rearranged to Gross = (Net + Deductions) / (1 − TaxRate). Adding 0.5 before applying INT achieves conventional rounding to the nearest whole currency unit rather than truncation. The use of 1.0-T rather than 1-T is stylistic but has no functional difference.

Notable Techniques and Observations

  • The dollar sign in the output string ("REQUIRED GROSS PAY=$ ") indicates the program was written for a North American audience.
  • No input validation is performed beyond the tax-rate normalisation; entering T=1 (100% tax) would cause a division-by-zero error at line 80.
  • The REM at line 5 serves solely as a program title label; it has no effect on execution.
  • Line numbers 8 and 9 suggest the header display was added after the original line 10 was written, fitting content into the gap.

Variable Summary

VariableMeaning
NDesired net (take-home) pay
TEffective tax rate (normalised to decimal)
DOther fixed deductions
GCalculated required gross pay

Content

Appears On

Assembled by Tim Ward from many sources. Contains programs 10051 – 10121.

Related Products

Related Articles

Related Content

Image Gallery

Source Code

   5 REM NETPAY
   8 PRINT TAB (5);"NET PAY CALCULATION"
   9 PRINT 
  10 PRINT "ENTER RQD NET PAY"
  20 INPUT N
  21 PRINT N
  30 PRINT "EFFECTIVE TAX RATE"
  40 INPUT T
  41 PRINT T
  45 IF T<1 THEN GOTO 60
  50 LET T=T/100
  60 PRINT "ENTER OTHER DEDUCTIONS"
  70 INPUT D
  71 PRINT D
  80 LET G=INT ((N+D)/(1.0-T)+.5)
  90 PRINT "REQUIRED GROSS PAY=$ ";G
 100 STOP 
 110 SAVE "1011%6"
 120 LIST 

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

People

No people associated with this content.

Scroll to Top