Here is an improved version.
DIM jbeans AS SINGLE
DIM goods(6) AS STRING
DIM locations(6) AS STRING
DIM price(6) AS INTEGER
DIM inbackpack(6) AS INTEGER
DIM picknumber(6) AS INTEGER
DIM bust AS INTEGER
DIM bsl AS STRING
DIM buywhat AS INTEGER
DIM howmanyb AS INTEGER
DIM sellwhat AS INTEGER
DIM howmanys AS INTEGER
DIM yourmoney AS INTEGER
DIM location AS INTEGER
DIM daycounter AS INTEGER
DIM debt AS INTEGER
DIM doesntmatter AS STRING
DIM visls AS STRING
DIM paynow AS STRING
DIM paydebt AS INTEGER
DIM endtotal AS INTEGER
DIM playagain AS STRING
DIM instructions AS STRING
DIM minutes AS INTEGER
DIM anothertransaction AS STRING
DIM backpackcapacity AS INTEGER
DIM canafford AS INTEGER
DIM buybackpack AS STRING
DIM bustagain AS INTEGER
DIM highscore AS INTEGER
DIM playername AS STRING
DIM currentname AS STRING
PRINT "Press enter to continue..."
SLEEP
INPUT doesntmatter
CLS
SLEEP 1
CLS
OPEN "candyscores.txt" FOR INPUT AS #1
INPUT #1, highscore
CLOSE #1
OPEN "candynames.txt" FOR INPUT AS #2
INPUT #2, playername
CLOSE #2
PRINT "High score: "; playername; highscore
PRINT " "
PRINT " "
PRINT " "
PRINT " "
PRINT " "
PRINT " "
PRINT " "
PRINT "Written by anarchronism...Creative Commons 2011 "
PRINT " "
PRINT " WELCOME TO THE PLAYGROUND"
SLEEP 1
PRINT
400 PRINT "Would you like instructions? (yes or no)"
INPUT instructions
instructions = UCASE$(instructions)
SELECT CASE instructions
CASE "YES"
CLS
PRINT "It's recess time again, and that means lunch is coming up. Your"
PRINT "stomach is growling, but it looks like Mom packed you something"
PRINT "green and leafy... You're a fourth grader! You want REAL food!"
PRINT
PRINT "You're going to have to wrangle up some lunch money yourself, and"
PRINT "that means doing what you do best--clandestine playground candy sales!"
PRINT "You get a loan of 40 pennies from Billy the Bully and you've got until"
PRINT "recess is over to pay him back with interest, otherwise you'll see"
PRINT "exactly how he got his name..."
PRINT
PRINT "You can visit Billy to make payments on your loan at his hangout"
PRINT "under the swings any time. Make sure to keep track of your debt and"
PRINT "how many minutes of recess have gone by. Buy and sell by visiting"
PRINT "different locations and monitoring prices for different goods."
PRINT
PRINT "Buy low, sell high, and good luck!"
PRINT
PRINT "Press enter to continue..."
INPUT doesntmatter
GOTO 300
CASE "NO"
CLS
GOTO 300
CASE ELSE
PRINT "Huh?"
GOTO 400
END SELECT
300
CLS
PRINT "How many minutes(turns) of recess do you want this game to be?"
PRINT
PRINT "5 is hard, 15 is medium, 25 is easy"
PRINT
INPUT minutes
RANDOMIZE TIMER
CLS
backpackcapacity = 25
debt = 50
daycounter = 1
yourmoney = 40
goods(1) = "Jelly beans"
goods(2) = "Lollies"
goods(3) = "Taffiez"
goods(4) = "Chocolatez"
goods(5) = "Cookiez"
goods(6) = "Fudge Popz"
70
PRINT "Choose a location (by number):"
90 PRINT
PRINT "1. Swings"
PRINT "2. Slide"
PRINT "3. Basketball Court"
PRINT "4. Tire Swing"
PRINT "5. Monkey Bars"
PRINT "6. Time Out"
PRINT
INPUT "Location number:"; location
SELECT CASE location
CASE IS < 1
CLS
PRINT "Pick a number, smartass."
GOTO 90
CASE IS > 6
CLS
PRINT "Pick a number, smartass."
GOTO 90
CASE ELSE
GOTO 150
END SELECT
150
CLS
price(1) = 1 + INT(RND * 15)
10 price(2) = 10 + INT(RND * 70)
IF price(2) > 80 THEN
GOTO 10
END IF
20 price(3) = 75 + INT(RND * 100)
IF price(3) > 100 THEN
GOTO 20
END IF
30 price(4) = 90 + INT(RND * 160)
IF price(4) > 160 THEN
GOTO 30
END IF
40 price(5) = 150 + INT(RND * 200)
50 price(6) = 200 + INT(RND * 350)
bust = 1 + INT(RND * 100)
IF bust > 10 AND bust < 18 AND inbackpack(1) + inbackpack(2) + inbackpack(3) + inbackpack(4) + inbackpack(5) + inbackpack(6) > 0 THEN
CLS
PRINT "No candy on the playground!"
PRINT
PRINT "Principal Hardass caught you selling candy! She confiscates what she finds!"
FOR x = 1 TO 6
inbackpack(x) = inbackpack(x) / 2
NEXT x
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT "Press enter to continue..."
SLEEP
INPUT doesntmatter
END IF
IF bust > 0 AND bust < 9 THEN
CLS
PRINT "Hey man, wanna buy a bigger backpack? *SNIFF*"
PRINT
PRINT "Sniffly Tom wants to sell you a backpack that will hold 20 more"
PRINT "pieces of candy."
PRINT
750 PRINT "It'll cost 40 pennies. Do you accept?(yes or no)"
INPUT buybackpack
buybackpack = UCASE$(buybackpack)
SELECT CASE buybackpack
CASE "YES"
IF yourmoney < 40 THEN
PRINT "You can't afford that."
END IF
IF yourmoney >= 40 THEN
yourmoney = yourmoney - 40
backpackcapacity = backpackcapacity + 20
PRINT
PRINT "Thanks, man! *SNIFF* It'll pay for itself in no time!"
END IF
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT "Press enter to continue..."
SLEEP
INPUT doesntmatter
CASE "NO"
CLS
PRINT "Your loss...*SNIFF*"
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT "Press enter to continue..."
SLEEP
INPUT doesntmatter
CASE ELSE
PRINT "Huh?"
GOTO 750
END SELECT
END IF
IF bust > 49 AND bust < 60 THEN
price(1) = price(1) + 1 + INT(RND * 20)
PRINT "Principal Hardass cracked down on jelly beans! Prices are through"
PRINT "the roof!"
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT "Press enter to continue..."
SLEEP
INPUT doesntmatter
END IF
IF bust > 59 AND bust < 70 THEN
price(2) = price(2) + 1 + INT(RND * 45)
PRINT "Teachers are confiscating lollies! High prices!"
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT "Press enter to continue..."
SLEEP
INPUT doesntmatter
END IF
IF bust > 69 AND bust < 80 THEN
price(3) = price(3) + 1 + INT(RND * 110)
PRINT "Taffy bust! Prices are through the roof!"
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT "Press enter to continue..."
SLEEP
INPUT doesntmatter
END IF
IF bust > 79 AND bust < 90 THEN
price(4) = price(4) + 1 + INT(RND * 130)
PRINT "Chocolate fiends got busted by those asshole teachers!"
PRINT "Prices are up!"
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT "Press enter to continue..."
SLEEP
INPUT doesntmatter
END IF
IF bust > 89 AND bust < 95 THEN
price(5) = price(5) + 1 + INT(RND * 285)
PRINT "Cookie bust! Prices are through the roof!"
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT "Press enter to continue..."
SLEEP
INPUT doesntmatter
END IF
IF bust > 30 AND bust < 42 THEN
price(6) = price(6) + 1 + INT(RND * 500)
PRINT "They busted the ice cream peddlers! Fudge popz ain't cheap!"
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT "Press enter to continue..."
SLEEP
INPUT doesntmatter
END IF
IF location = 1 THEN
price(6) = price(6) + 1 + INT(RND * 150)
CLS
120 PRINT "Visit Billy the Bully?"
INPUT visls
visls = UCASE$(visls)
SELECT CASE visls
CASE "YES"
CLS
PRINT "Hey bub, how's the business comin'?"
PRINT
PRINT "Looks like you owe me "; debt; " pennies."
PRINT
130 PRINT "Pay now? (yes or no)"
INPUT paynow
paynow = UCASE$(paynow)
SELECT CASE paynow
CASE "YES"
CLS
PRINT "Good thinkin'. You don't wanna keep me waitin'."
PRINT
140 PRINT "How much do you pay? You owe "; debt
INPUT paydebt
IF paydebt > yourmoney THEN
PRINT "You don't have that much."
PRINT
GOTO 140
END IF
yourmoney = yourmoney - paydebt
debt = debt - paydebt
CLS
PRINT "You now owe Billy "; debt; " pennies."
CASE "NO"
CLS
PRINT "Fine. Suit yourself. We'll meet again, one way or another"
CASE ELSE
GOTO 130
END SELECT
CASE "NO"
CLS
GOTO 110
CASE ELSE
CLS
GOTO 120
END SELECT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT "Press enter to continue..."
INPUT doesntmatter
CLS
END IF
110
IF location = 2 THEN
price(5) = price(5) - 1 + INT(RND * 50)
END IF
IF location = 3 THEN
price(4) = price(4) - 1 + INT(RND * 15)
price(1) = price(1) + 1 + INT(RND * 5)
END IF
IF location = 6 THEN
bustagain = 1 + INT(RND * 100)
IF bustagain >= 85 AND inbackpack(1) + inbackpack(2) + inbackpack(3) + inbackpack(4) + inbackpack(5) + inbackpack(6) > 0 THEN
CLS
PRINT "That pompous student teacher caught you selling candy to the"
PRINT "kids in time out! She confiscates what she finds!"
FOR x = 1 TO 6
inbackpack(x) = inbackpack(x) / 2
NEXT x
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT "Press enter to continue..."
SLEEP
INPUT doesntmatter
END IF
price(3) = price(3) + 1 + INT(RND * 100)
price(4) = price(4) + 1 + INT(RND * 100)
price(5) = price(5) + 1 + INT(RND * 125)
price(6) = price(6) + 1 + INT(RND * 150)
END IF
500 CLS
PRINT "You have "; yourmoney; " pennies.", "Minute: "; daycounter, "Debt: "; debt
PRINT
PRINT "For sale:", "Price:", "In backpack:"
PRINT
PRINT "1. J-Beanz", price(1), inbackpack(1)
PRINT "2. Lolliez", price(2), inbackpack(2)
PRINT "3. Taffiez", price(3), inbackpack(3)
PRINT "4. Chocolatez", price(4), inbackpack(4)
PRINT "5. Cookiez", price(5), inbackpack(5)
PRINT "6. Fudge Popz", price(6), inbackpack(6)
PRINT
60 PRINT "Buy, sell, or leave?"
INPUT bsl
bsl = UCASE$(bsl)
SELECT CASE bsl
CASE "BUY"
PRINT
550 PRINT "Buy what? (Choose a number)"
canafford = 0
INPUT buywhat
IF buywhat < 1 OR buywhat > 6 THEN
PRINT "Huh?"
GOTO 550
END IF
PRINT
PRINT goods(buywhat); " cost "; price(buywhat); " pennies."
PRINT
DO WHILE price(buywhat) * canafford <= yourmoney
canafford = canafford + 1
LOOP
canafford = canafford - 1
PRINT "You can afford "; canafford; "."
PRINT
PRINT "How many?"
INPUT howmanyb
PRINT
CLS
PRINT howmanyb; goods(buywhat); " cost you "; howmanyb * price(buywhat); " pennies."
IF howmanyb * price(buywhat) > yourmoney THEN
PRINT "You can't afford that."
PRINT
PRINT "Press enter to continue..."
SLEEP
INPUT doesntmatter
GOTO 500
END IF
IF howmanyb + inbackpack(1) + inbackpack(2) + inbackpack(3) + inbackpack(4) + inbackpack(5) + inbackpack(6) > backpackcapacity THEN
PRINT "You can only have up to "; backpackcapacity; " pieces of candy in your backpack!"
PRINT
PRINT "Press enter to continue"
SLEEP
INPUT doesntmatter
GOTO 500
END IF
inbackpack(buywhat) = inbackpack(buywhat) + howmanyb
yourmoney = yourmoney - howmanyb * price(buywhat)
PRINT
PRINT "You have "; yourmoney; " pennies and "; inbackpack(buywhat); goods(buywhat)
PRINT
520 PRINT "Perform another transaction at this location? (yes or no)"
INPUT anothertransaction
anothertransaction = UCASE$(anothertransaction)
SELECT CASE anothertransaction
CASE "YES"
CLS
GOTO 500
CASE "NO"
CLS
PRINT "Better get going!"
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT "Press enter to continue..."
SLEEP
INPUT doesntmatter
CLS
CASE ELSE
PRINT
PRINT "Huh?"
GOTO 520
END SELECT
CASE "SELL"
PRINT
650 PRINT "Sell what? (Choose a number)"
INPUT sellwhat
IF sellwhat < 0 OR sellwhat > 6 THEN
PRINT "Huh?"
GOTO 650
END IF
IF inbackpack(sellwhat) < 1 THEN
PRINT "You don't have any "; goods(sellwhat)
GOTO 60
END IF
PRINT
PRINT goods(sellwhat); " cost "; price(sellwhat); " pennies."
PRINT
PRINT "How many do you sell? You have "; inbackpack(sellwhat)
INPUT howmanys
PRINT
CLS
IF howmanys > inbackpack(sellwhat) THEN
PRINT "You don't have that much to sell."
PRINT
PRINT "Press enter to continue..."
SLEEP
INPUT doesntmatter
GOTO 500
END IF
PRINT howmanys; goods(sellwhat); " earn you "; howmanys * price(sellwhat); " pennies."
inbackpack(sellwhat) = inbackpack(sellwhat) - howmanys
yourmoney = yourmoney + howmanys * price(sellwhat)
PRINT
PRINT "You have "; yourmoney; " pennies and "; inbackpack(sellwhat); goods(sellwhat)
PRINT
510 PRINT "Perform another transaction at this location? (yes or no)"
INPUT anothertransaction
anothertransaction = UCASE$(anothertransaction)
SELECT CASE anothertransaction
CASE "YES"
CLS
GOTO 500
CASE "NO"
CLS
PRINT "Better get going!"
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT "Press enter to continue..."
SLEEP
INPUT doesntmatter
CLS
CASE ELSE
PRINT
PRINT "Huh?"
GOTO 510
END SELECT
CASE "LEAVE"
CLS
PRINT "Nothing to see here!"
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT "Press enter to continue..."
SLEEP
INPUT doesntmatter
CLS
GOTO 80
CASE ELSE
PRINT "What?"
GOTO 60
END SELECT
80 daycounter = daycounter + 1
debt = debt * 1.25
IF daycounter = minutes + 1 THEN
CLS
endtotal = yourmoney - debt
PRINT "BRRRR-IIIINNG!"
PRINT "That's the bell! Recess is over!"
IF endtotal < 0 THEN
PRINT "You lose! Billy's running toward you, cracking his knuckles!"
PRINT
PRINT endtotal; " pennies..."
PRINT
OPEN "candyscores.txt" FOR INPUT AS #1
INPUT #1, highscore
CLOSE #1
OPEN "candynames.txt" FOR INPUT AS #2
INPUT #2, playername
CLOSE #2
PRINT "High score: "; playername; highscore
PRINT
330 PRINT "Play again?"
INPUT playagain
playagain = UCASE$(playagain)
SELECT CASE playagain
CASE "YES"
CLS
GOTO 300
CASE "NO"
CLS
PRINT "Alright..."
END
CASE ELSE
CLS
PRINT "What?"
PRINT
GOTO 330
END SELECT
END IF
IF endtotal = 0 THEN
PRINT "You just made it! You broke even!"
PRINT
OPEN "candyscores.txt" FOR INPUT AS #1
INPUT #1, highscore
CLOSE #1
OPEN "candynames.txt" FOR INPUT AS #2
INPUT #2, playername
CLOSE #2
PRINT "High score: "; playername; highscore
PRINT
320 PRINT "Play again?"
INPUT playagain
playagain = UCASE$(playagain)
SELECT CASE playagain
CASE "YES"
CLS
GOTO 300
CASE "NO"
CLS
PRINT "Alright..."
END
CASE ELSE
CLS
PRINT "What?"
PRINT
GOTO 320
END SELECT
END IF
IF endtotal > 1 THEN
PRINT
PRINT "You came out ahead!"
PRINT endtotal; " pennies!"
PRINT
OPEN "candyscores.txt" FOR INPUT AS #1
INPUT #1, highscore
CLOSE #1
OPEN "candynames.txt" FOR INPUT AS #2
INPUT #2, playername
CLOSE #2
IF endtotal <= highscore THEN
PRINT "High score: "; playername; highscore
PRINT
END IF
IF endtotal > highscore THEN
PRINT "New high score!"
PRINT
PRINT "Previous high score: "; playername; highscore
PRINT
PRINT "Enter your name:"
INPUT currentname
OPEN "candynames.txt" FOR OUTPUT AS #3
WRITE #3, currentname
CLOSE #3
OPEN "candyscores.txt" FOR OUTPUT AS #4
WRITE #4, endtotal
CLOSE #4
CLS
PRINT "High score: "; currentname; endtotal
PRINT
END IF
310 PRINT "Play again?"
INPUT playagain
playagain = UCASE$(playagain)
SELECT CASE playagain
CASE "YES"
CLS
GOTO 300
CASE "NO"
CLS
PRINT "Alright..."
END
CASE ELSE
CLS
PRINT "What?"
PRINT
GOTO 310
END SELECT
END IF
END IF
GOTO 70
There is greater variety in candy prices in this version, so there's more potential for earning huge amounts of money, which makes it feel more fun and less studious.
I've also included the capability for a high score to be saved. In order for the program to work, you'll need to create a "candynames.txt" file and a "candyscores.txt" file in your QB64 folder, and then put a character string in candynames.txt and a number in candyscores.txt.
For example, I start off candynames.txt with "Nobody" written in it and candyscores.txt with "0" written in it.
Is there some kind of create-text-file command/function I can use in my code to make it so that users don't have to create the text files themselves?
Thanks to Clippy and OlDos for giving it a try.