Ad Profit

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 advertising campaign profit, taking inputs for retail price, wholesale cost, advertising expenditure, and quantity sold. It then computes net profit using the formula E = A×B − A×C − D. A break-even mode is triggered when the user enters 0 for quantity sold, whereupon the program instead solves for the number of units required to achieve a desired profit target using the rearranged formula A = (F+D)/(B−C). The program loops continuously, clearing the screen and restarting the input sequence after each calculation.


Program Analysis

Program Structure

The program is divided into clearly delineated functional blocks:

  1. Lines 1–4: Title display and instructions
  2. Lines 10–120: Input collection (retail price, wholesale cost, ad cost, quantity sold)
  3. Line 130: Branch decision — normal profit vs. break-even mode
  4. Lines 200–220: Normal profit calculation and display
  5. Lines 300–350: Break-even unit calculation
  6. Lines 400–450: Loop control — wait for keypress, clear screen, restart
  7. Lines 475–600: Save and auto-run block (never reached in normal execution)

Key Variables

VariableMeaning
BRetail (list) price per unit
CManufacturing or wholesale cost per unit
DTotal advertising cost
AQuantity sold (or computed break-even quantity)
ECalculated profit
FDesired profit (break-even mode input)

Profit Calculation

In normal mode (line 200), profit is computed as E = A*B - A*C - D, which represents total revenue minus total cost-of-goods minus fixed advertising spend. This could be simplified to E = A*(B-C) - D, but the expanded form is functionally correct.

In break-even mode (line 330), the formula is algebraically rearranged to A = (F+D)/(B-C), solving for the number of units needed. Entering 0 for profit wanted (F=0) gives the true break-even unit count.

Key BASIC Idioms

  • The keypress-wait loop at line 430 uses IF INKEY$="" THEN GOTO 430, a standard polling idiom on this platform.
  • Each INPUT statement is preceded by a PRINT prompt and followed by an echoing PRINT of the entered value, giving a clean audit trail on screen.
  • The infinite main loop is driven by GOTO 10 at line 450 after a CLS, recycling the program without restarting it.

Notable Anomalies

  • Lines 475 (CLEAR), 500 (SAVE), and 600 (RUN) are unreachable during normal execution; the loop at line 450 never falls through to them. They exist solely as a tape-saving convenience to be run manually.
  • No input validation is performed: entering identical values for B and C (i.e., zero margin) in break-even mode causes a division-by-zero error at line 330.
  • The PRINT A echo at line 120 prints the raw numeric value of the quantity entered rather than formatting it with a label, which is inconsistent with the labelled echoes used for B, C, and D.

Appears On

Tape 1001 of the Timex Sinclair Public Domain Library. Assembled by Tim Ward from many sources.

Image Gallery

Source Code

   1 REM AD PROFIT
   2 PRINT "%A%D% %C%A%M%P%A%I%G%N% %P%R%O%F%I%T"
   3 PRINT "ANSWER QUESTIONS AS REQUESTED.  IF YOU WISH TO KNOW HOW MANY UNITS TO SELL TO BREAK EVEN,ANSWER 0 TO NUMBER SOLD AND $ PROFIT WANTED"
   4 PRINT 
  10 PRINT "ITEM LIST/RETAIL PRICE: ";
  20 INPUT B
  30 PRINT "$";B
  40 PRINT "MFG OR WHOLESALE COST: ";
  50 INPUT C
  60 PRINT "$";C
  70 PRINT "AD COST: ";
  80 INPUT D
  90 PRINT "$";D
 100 PRINT "QUANTITY SOLD: ";
 110 INPUT A
 120 PRINT A
 130 IF A=0 THEN GOTO 300
 200 LET E=A*B-A*C-D
 210 PRINT "$";E;" PROFIT"
 220 GOTO 400
 300 PRINT "PROFIT WANTED: $ ";
 310 INPUT F
 320 PRINT F
 330 LET A=(F+D)/(B-C)
 340 PRINT "YOU MUST SELL  ";A
 350 PRINT "FOR $ ";F;" PROFIT"
 400 PRINT 
 410 PRINT 
 420 PRINT "FOR MORE,PRESS ANY KEY"
 430 IF INKEY$="" THEN GOTO 430
 440 CLS 
 450 GOTO 10
 475 CLEAR 
 500 SAVE "1001%6"
 600 RUN 

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