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:
- Lines 1–4: Title display and instructions
- Lines 10–120: Input collection (retail price, wholesale cost, ad cost, quantity sold)
- Line 130: Branch decision — normal profit vs. break-even mode
- Lines 200–220: Normal profit calculation and display
- Lines 300–350: Break-even unit calculation
- Lines 400–450: Loop control — wait for keypress, clear screen, restart
- Lines 475–600: Save and auto-run block (never reached in normal execution)
Key Variables
| Variable | Meaning |
|---|---|
B | Retail (list) price per unit |
C | Manufacturing or wholesale cost per unit |
D | Total advertising cost |
A | Quantity sold (or computed break-even quantity) |
E | Calculated profit |
F | Desired 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
INPUTstatement is preceded by aPRINTprompt and followed by an echoingPRINTof the entered value, giving a clean audit trail on screen. - The infinite main loop is driven by
GOTO 10at line 450 after aCLS, 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
BandC(i.e., zero margin) in break-even mode causes a division-by-zero error at line 330. - The
PRINT Aecho 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 forB,C, andD.
Content
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.
