Author Topic: Lemonade Stand 2  (Read 5738 times)

0 Members and 1 Guest are viewing this topic.

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Lemonade Stand 2
« Reply #15 on: September 02, 2020, 02:21:24 pm »
Oh I see what I forgot to do! You were right. I didn't deduct the cups from the daily amounts.

line 57 (now line 58): LOCATE 12, 1: PRINT "You have made $"; sales5 - pitchersold

This should deduct the cups amount too... I will change that.... Here we go, this should work:

Edit: I also forgot the advertisement cost in the daily amounts. So I just deducted that price as well. It seems to work fine now. Thank you again for telling me.
line 57 (now line 58): LOCATE 12, 1: PRINT "You have made $"; sales5 - pitchersold - ads

Code: QB64: [Select]
  1. _TITLE "Lemonade Stand 2"
  2. SCREEN _NEWIMAGE(800, 600, 32)
  3. begin:
  4. PRINT "                                        Lemonade Stand 2"
  5. PRINT "                                         by  SierraKen"
  6. PRINT "You start with $20."
  7. PRINT "There are 5 cups per pitcher."
  8. PRINT "There are 30 cups per package of cups."
  9. PRINT "There will be weather, donations, and advertising."
  10. PRINT "Cup packages and pitchers can only be used for one day."
  11. INPUT "                                    Press Enter to begin.", a$
  12. money = 20
  13. ads = 0
  14. day = 0
  15.     day = day + 1
  16.     LOCATE 1, 1: PRINT "Day: "; day
  17.     weather = INT(RND * 8) + 1
  18.     IF weather = 1 THEN w$ = "Hot"
  19.     IF weather = 2 THEN w$ = "Sunny"
  20.     IF weather = 3 THEN w$ = "Cloudy"
  21.     IF weather = 4 THEN w$ = "Windy"
  22.     IF weather = 5 THEN w$ = "Rainy"
  23.     IF weather = 6 THEN w$ = "Cold"
  24.     IF weather = 7 THEN w$ = "Snowy"
  25.     IF weather = 8 THEN w$ = "Hail"
  26.     LOCATE 2, 1: PRINT "Weather: "; w$
  27.     pitcher = INT(5 / weather) + 2
  28.     LOCATE 4, 1: PRINT "Cost Of One Pitcher Of Lemonade Today: $"; pitcher
  29.     cups = INT(RND * 7) + 2
  30.     LOCATE 5, 1: PRINT "Cost Of One Package Of Cups Today: $"; cups
  31.     LOCATE 6, 1: INPUT "Price Of Each Glass $", price
  32.     sales1 = INT((INT(RND * 92) + 8) / weather)
  33.     donations = INT(RND * 4) + 1
  34.     IF donations = 2 THEN
  35.         donatedmoney = INT(RND * 20) + 1
  36.         money = money + donatedmoney
  37.     END IF
  38.     LOCATE 7, 1: INPUT "Amount to spend on advertising: $", ads
  39.     sales2 = (INT(RND * sales1) / price) + sales1
  40.     sales3 = INT(RND * (ads * 2)) + 3
  41.     sales4 = INT(sales2 + sales3)
  42.     sales5 = sales4 * price
  43.     LOCATE 9, 1: PRINT "Cups Of Lemonade Sold: "; sales4; " glasses today."
  44.     pitchersused = INT(sales4 / 5) + 1
  45.     LOCATE 10, 1: PRINT "Pitchers Used"; pitchersused
  46.     pitchersold = pitchersused * pitcher
  47.     cupsold = INT(sales4 / 30) + 1
  48.     cupsdeduct = cupsold * cups
  49.     LOCATE 11, 1: PRINT "Cup Packages Used:"; cupsold
  50.     LOCATE 12, 1: PRINT "You have made $"; sales5 - pitchersold - cupsdeduct - ads
  51.     money = money + sales5 - ads
  52.     money = money - pitchersold
  53.     money = money - cupsdeduct
  54.     LOCATE 13, 1: PRINT "Donations: "; donatedmoney
  55.     LOCATE 14, 1: PRINT "Total Income: $"; money
  56.     IF money = 0 OR money < 0 THEN GOTO done:
  57.     LOCATE 16, 1: PRINT "Do you want to sell tomorrow (Y/N)?"
  58.     yesno:
  59.     yn$ = INKEY$
  60.     IF yn$ = "Y" OR yn$ = "y" THEN GOTO more:
  61.     IF yn$ = "N" OR yn$ = "n" THEN GOTO done:
  62.     GOTO yesno:
  63.     more:
  64.     CLS
  65. done:
  66. PRINT "Your Total Days: "; day
  67. PRINT "Your Total Money: "; money
  68. PRINT "Do you want to play again (Y/N)"
  69. again:
  70. again$ = INKEY$
  71. IF again$ = "y" OR again$ = "Y" THEN GOTO begin:
  72. IF again$ = "n" OR again$ = "N" THEN END
  73. GOTO again:
  74.  
« Last Edit: September 02, 2020, 02:35:23 pm by SierraKen »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Lemonade Stand 2
« Reply #16 on: September 02, 2020, 03:24:07 pm »
Man I am tempted to open a stand and go in competition with you ;-))

Least lines of code and yet clearly presented. When the weather gets bad I will also sell hot coffee and umbrellas or snow shovels. Ha! actually a lunch truck might be interesting.

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Lemonade Stand 2
« Reply #17 on: September 02, 2020, 04:46:06 pm »
ROFL that would be awesome! B+'s Wild and Crazy Lunch Truck!