You have been placed in charge of a small lemonade stand at College and Yonge for a week. You start off with $10 in your pocket and you should try to make as much money as possible.
Weather conditions (cloudy, sunny, rainy, stormy, hot, or snowy) affect customer demand through lookup tables stored in the string array `a$`, whose 17th and 18th character positions hold CHR$ codes used as raw numeric parameters in the sales calculation. The demand formula at line 600 uses a price-sensitivity factor `1/(10-(l-p))` to reduce sales when the selling price strays from the wholesale cost, and a random vandalism event can fire after day 2, docking $20 from funds. The shop display is drawn with block-graphic characters and animated PLOT/DRAW routines depicting two lemon jugs filling line by line.
Program Analysis
Program Structure
The program is organized into a main game loop and several subroutines and branching sections:
- Lines 10–50: Setup, title screen, and initial subroutine call
- Lines 60–70: Variable initialization (money
m=1000i.e. $10, rentr=50, pricep=3) - Lines 80–760: Main daily game loop — weather, input, sales simulation, bookkeeping
- Lines 780–1100: Graphics subroutine (shop display with animated jugs)
- Lines 1110–1180: Bankruptcy ending
- Lines 1190–1300: Success ending (7-day completion)
- Lines 1320–1400: Random police/vandalism event
- Lines 1410–1480: Instructions subroutine
- Lines 1490–1570: “Quit after vandalism” ending
Variable Roles
| Variable | Role |
|---|---|
m | Total money in cents (starts at 1000 = $10.00) |
p | Wholesale cost per cup in cents (starts at 3) |
r | Daily rent in cents (50 = $0.50) |
l | Player’s chosen sale price per cup in cents |
c | Number of cups prepared by the player |
d | Weather type index (1–6) |
a | Cups actually sold (also reused as loop variable) |
n | Raw demand value before price adjustment |
day | Current day counter (1–7) |
w$ | 6×18 string array of weather names |
a$ | 6×18 string array; positions 17–18 hold demand parameters as CHR$ codes |
Weather and Demand System
Six weather types are stored in w$(1..6). Demand parameters for each weather type are encoded as CHR$ values stored at character positions 17 and 18 of the corresponding row in a$. The raw demand is computed at line 590:
LET n=RND*CODE(a$(d,17))+RND*CODE(a$(d,18))
This sums two independent uniform random values, each scaled by a weather-specific constant, producing a roughly triangular distribution. The effective demand parameter pairs are:
| Weather | Param 17 | Param 18 | Max raw demand |
|---|---|---|---|
| Cloudy | 60 | 40 | 100 |
| Sunny | 80 | 90 | 170 |
| Rainy | 15 | 15 | 30 |
| Stormy | 7 | 10 | 17 |
| Hot | 105 | 130 | 235 |
| Snowy | 2 | 8 | 10 |
Sales Calculation and Price Sensitivity
Line 600 applies a price penalty to the raw demand:
LET a=INT(n-(1/(10-(l-p)))*n)
This reduces demand proportionally based on how far the sale price l exceeds the wholesale cost p. When l-p approaches 10, the denominator approaches zero and the formula produces a near-total wipeout of sales. The sale price is capped at 40 cents (line 450), so with p starting at 3, the maximum spread is 37, making the denominator negative and actually reversing the sign — a mathematical anomaly that rewards extreme overpricing with boosted (not penalized) demand when l-p > 10. This is a bug in the economic model.
Variable Reuse Conflict
The variable a is used both as the FOR loop counter in the graphics subroutine (lines 810, 860, 870, 890) and as the computed cups-sold value (line 600 onward). Since the graphics subroutine at line 780 is called before a is used for sales (line 590), this does not cause an in-game conflict, but it is a fragile design. The subroutine variable a in the graphics section also shadows the outer a, since BASIC uses a single flat variable namespace.
String Array as Data Store
Rather than storing demand parameters in a numeric array, the author stores them as single characters inside a string array a$ and retrieves their values with CODE(). This is an unconventional but memory-compact technique, embedding numeric data within a structure primarily used for text. Positions 1–16 of each a$ row are left as spaces (the default fill for DIM’d string arrays), and only positions 17 and 18 carry meaningful data.
Graphics Subroutine
The shop display subroutine (lines 780–1100) draws a storefront using block graphic characters (█ rendered as \:: escapes) to create walls, a counter, and a sign. Two animated lemon jugs are drawn using PLOT/DRAW sequences with a short PAUSE inside the loop to create a filling animation effect. The shop sign at line 930 uses CHR$ 8 (cursor left) combined with OVER 1 and OVER 0 to overlay a forward slash over the price display, simulating a cents notation (e.g., “3¢/cup”) without a dedicated character.
Clock Animation
Lines 510–560 animate a clock advancing from 9 o’clock through the business day. The hour variable t increments and wraps at 13 back to 1 (line 550), cycling until it reaches 8 (line 560), at which point the shop closes. Each tick uses PAUSE 30, making one simulated “hour” last about 0.6 seconds of real time.
Randomized Wholesale Price Creep
Line 730 increments the wholesale cost p by 1 cent with 40% probability each day (IF RND>.6 THEN LET p=p+1), creating a gradual cost-of-goods inflation that adds economic pressure over the week without requiring player input.
Vandalism Event
Line 90 fires a random vandalism event with approximately 3% probability, but only after day 2. This branches to the police report section (lines 1320–1400), which deducts $20 (2000 cents) from m and gives the player the option to quit (INKEY$="q") or absorb the loss and continue. Quitting leads to a separate “broke” ending at line 1490.
Key BASIC Idioms
- Busy-wait input loops:
IF INKEY$="" THEN GO TO nused at multiple points - Inline screen clearing via
PRINT AT r,c;"...spaces..."rather than full CLS - All monetary values stored internally as integer cents to avoid floating-point rounding, divided by 100 only at display time
- DIM of
w$anda$inside the main loop (line 130, 200) — these are re-dimensioned each day, which is functionally harmless but wasteful
Notable Anomalies
- Re-dimensioning
w$anda$with DIM on every pass through the day loop (lines 130, 200) resets the arrays and forces all values to be re-assigned each time — an inefficiency that works correctly but wastes time - The demand formula breaks down when
l-p >= 10, producing negative or zero denominators; no guard is present - Line 1150 contains a missing space:
"...make as much money as possible"and similar strings are split across lines in a way that can cause words to run together in the printed output (e.g.,"youfailed") - The unused variable
z$captures the ENTER keypress at line 30 as a string INPUT, which is functional but unconventional — a keypress loop would be more idiomatic
Content
Source Code
10 REM From Personal Software Spring 1984 Page 78
20 BORDER 1: PAPER 1: INK 7: CLS
30 PRINT AT 10,5;"Press 'ENTER' to begin": INPUT z$
40 CLS
50 GO SUB 1410
60 LET l=0: LET m=1000: LET r=50: LET p=3
70 LET day=1
80 GO SUB 780
90 CLS : IF RND>.97 AND day>2 THEN GO TO 1320
100 PRINT AT 1,2;"REPORT"
110 PLOT 14,159: DRAW 52,0
120 PRINT '" DAY ";day
130 DIM w$(6,18)
140 LET w$(1)="cloudy"
150 LET w$(2)="sunny"
160 LET w$(3)="rainy"
170 LET w$(4)="stormy"
180 LET w$(5)="hot"
190 LET w$(6)="snowy"
200 DIM a$(6,18)
210 LET a$(1,17)=CHR$ 60
220 LET a$(2,17)=CHR$ 80
230 LET a$(3,17)=CHR$ 15
240 LET a$(4,17)=CHR$ 7
250 LET a$(5,17)=CHR$ 105
260 LET a$(6,17)=CHR$ 2
270 LET a$(1,18)=CHR$ 40
280 LET a$(2,18)=CHR$ 90
290 LET a$(3,18)=CHR$ 15
300 LET a$(4,18)=CHR$ 10
310 LET a$(5,18)=CHR$ 130
320 LET a$(6,18)=CHR$ 8
330 LET d=INT (RND*6+1)
340 PRINT '" The weather today is ";w$(d, TO 16)
350 PRINT '" Lemonade costs ";p;" cents/cup"
360 PRINT '" Total money = $";m/100
370 IF m<0 THEN GO TO 1110
380 PRINT AT 20,0;" How many cups to be made? "
390 INPUT c
400 IF c>m/p THEN PRINT AT 12,0;"You haven't enough money"
410 IF c>m/p THEN GO TO 390
420 PRINT AT 12,0;" No. of cups made is ";c;" "
430 PRINT AT 20,0;" Sale price for each cup? "
440 INPUT l
450 IF l>40 THEN GO TO 440
460 PRINT AT 14,0;" Sale price=";l;"c";CHR$ 8; OVER 1;"/"; OVER 0;" per cup "
470 PAUSE 50
480 PRINT AT 20,0;"Press any key to open your shop "
490 IF INKEY$="" THEN GO TO 490
500 GO SUB 780
510 LET t=9
520 PRINT AT 2,1;"Time: ";t;" o'clock "
530 PAUSE 30
540 LET t=t+1
550 IF t=13 THEN LET t=1
560 IF t<>8 THEN GO TO 520
570 PRINT AT 9,10; PAPER 0; INK 6;" CLOSED "
580 PAUSE 50
590 LET n=RND*CODE (a$(d,17))+RND*CODE (a$(d,18))
600 LET a=INT (n-(1/(10-(l-p)))*n)
610 IF a>c THEN LET a=c
620 CLS : PRINT AT 1,2;"SALES REPORT";AT 1,25;"Day ";day
630 PLOT 14,159: DRAW 98,0
640 PRINT '" No. of cups sold=";a
650 PRINT '" Money in the till=$";(a*l)/100
660 PRINT ''" Wholesalers bill=$";(c*p)/100
670 PRINT ''" Rent=$";r/100
680 PRINT ''" PROFIT FOR THE DAY=$";(l*a-c*p-r)/100
690 LET m=m+(l*a-c*p-r)
700 IF m<0 THEN GO TO 1110
710 LET day=day+1
720 IF day=8 THEN GO TO 1190
730 IF RND>.6 THEN LET p=p+1
740 PRINT AT 20,0;" Press any key to continue "
750 IF INKEY$="" THEN GO TO 750
760 GO TO 80
770 STOP
780 REM ------- graphics
790 CLS
800 BORDER 6: PAPER 1
810 FOR a=15 TO 21
820 PRINT AT a,0; INK 4;"\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::"
830 NEXT a
840 PRINT AT 7,11; PAPER 7; INK 0;" LEMONADE "
850 INK 6: PRINT AT 8,8;"\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::"
860 FOR a=9 TO 12
870 PRINT AT a,9;"\::";AT a,22;"\::"
880 NEXT a
890 FOR a=13 TO 17
900 PRINT AT a,9;"\::\::\::\::\::\::\::\::\::\::\::\::\::\::"
910 NEXT a
920 PRINT AT 9,10;" OPEN "
930 PRINT AT 14,10; PAPER 7; INK 0;"PRICE=";l;"c";CHR$ 8; OVER 1;"/"; OVER 0
940 INK 5
950 PLOT 90,81: DRAW 1,-9
960 PLOT 98,81: DRAW -1,-9
970 PLOT 90,81: DRAW 8,0
980 FOR a=72 TO 78
990 PLOT 91,a: DRAW 6,0
1000 PAUSE 5
1010 NEXT a
1020 PLOT 105,81: DRAW 1,-9
1030 PLOT 113,81: DRAW -1,-9
1040 PLOT 105,81: DRAW 8,0
1050 FOR a=72 TO 78
1060 PLOT 106,a: DRAW 6,0
1070 PAUSE 5
1080 NEXT a
1090 PAUSE 30
1100 RETURN
1110 PAUSE 200: CLS
1120 PRINT AT 1,2;"FINAL REPORT"
1130 PLOT 14,159: DRAW 99,0
1140 PRINT ''" You lasted for ";day;" days, until you ran out of money"
1150 PRINT '" You didn't do very well, as youfailed as a successful shop keeper"
1160 PRINT AT 20,0;" Press 'ENTER' for another try!"
1170 IF INKEY$="" THEN GO TO 1170
1180 CLS : GO TO 40
1190 PAUSE 200
1200 CLS
1210 PRINT AT 1,2;"FINAL REPORT"
1220 PLOT 14,159: DRAW 99,0
1230 PRINT ''" You completed your week in business and made a profit of "
1240 PRINT AT 10,5;"Total money=$";m/100
1250 PRINT AT 11,5;"minus loan of $10"
1260 PLOT 39,79: DRAW 136,0
1270 PRINT AT 13,5;"PROFIT =$";(m/100)-10
1280 PRINT AT 20,0;" Press 'ENTER' for another try!"
1290 IF INKEY$="" THEN GO TO 1290
1300 CLS : GO TO 40
1310 STOP
1320 CLS : BORDER 1
1330 PRINT AT 1,2;"POLICE REPORT"
1340 PLOT 14,159: DRAW 105,0
1350 PRINT '''" The police have informed you that vandals have damaged your property. The cost of repairs is$20.00."
1360 PRINT ''" If you cannot meet this bill press 'Q'. If you want to carry on your business press 'ENTER'."
1370 IF INKEY$="q" THEN GO TO 1490
1380 IF INKEY$="" THEN GO TO 1380
1390 LET m=m-2000
1400 GO TO 80
1410 REM -------instructions
1420 PRINT AT 1,9;"LEMONADE STAND"
1430 PLOT 70,159: DRAW 114,0
1440 PRINT ''" You have been placed in charge of a small lemonade stand at College and Yonge for a week. You start off with $10 in your pocket and you should try to make as much money as possible."
1450 PRINT '" You are given the report for the day and you only need to make two decisions: How many cups to prepare, and For how much should each be sold ?"
1460 PRINT '''" Press 'ENTER' to begin"
1470 IF INKEY$="" THEN GO TO 1470
1480 RETURN
1490 PAUSE 200
1500 CLS
1510 PRINT AT 1,2;"BROKE"
1520 PLOT 14,159: DRAW 42,0
1530 PRINT ''" You finally ended up broke!"
1540 PRINT ''" The police have just told you that the vandals are still on the loose."
1550 PRINT AT 20,0;" Press 'ENTER' for another try!"
1560 IF INKEY$="" THEN GO TO 1560
1570 GO TO 30
1580 SAVE "lemonade" LINE 1
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.

