Need help programming this lemonade stand game on this website http://www.coolma
ID: 3840056 • Letter: N
Question
Need help programming this lemonade stand game on this website http://www.coolmath-games.com/0-lemonade-stand in python 3.1.2 on windows computer I need a flowchart, pseudocode and a complete working program for the game in the link given and all the info I need is listed below is listed below.
what I need to program in python:
introduction to the lemonade stand game
how long would you like to play?
in the game, you can play 7 days 14 days 30 days
start the game with $20.00
next, in the game, you buy inventory/purchasing
buy cups
25 cups for .97
50 cups for $1.63
100 cups for$ 2.86
Lemons
10 for .61
30 for $2.15
75 for $4.10
Cups of sugar
8 for .55
20 for $1.75
48 for $3.36
Ice cups
100 for .98
250 for $2.20
500 for $3.62
Temperature
Set the Random temperature for each day.
Weather forecast: hazy, raining, sunny, breeze
Setting the price for the game
before you start the game you need Price/quality control
How much they want customers to pay per cup of lemonade.
How many lemons they want to use in each pitcher of lemonade.
How many cups of sugar do they want to use in one pitcher of lemonade
How many cups of ice that want to use in each pitcher of lemonade.
In the game and at the end
Also, they can go bankrupt in the game if they run out of money.
And they can also sell out of lemonade.
And at the end of the day, you need to tell them how much profit they have made that day.
also, tell them their customer satisfaction in a % form and their popularity in a %
Explanation / Answer
#!/usr/bin/env python
""" Simple version of classic lemonade stand game. Written in Python 2.7
"""
__author__ = 'jeremy osborn'
import random
class LemonadeStand:
""" LemonadeStand class with three methods - make_lemonade, sell_lemonade, display_data.
"""
def __init__(self):
""" setup initial parameters. weather is randomized."""
self.day = 0
self.cash = 100
self.lemonade = 0
self.lemonade_price = random.randrange(1, 10)
self.weather = random.randrange(50, 100)
def make_lemonade(self):
""" Make lemonade to sell later. Cost to make lemonade changes each day."""
while True:
try:
lemonade = int(raw_input('How many cups of lemonade will you make (1-10)? '))
if lemonade in range(1, 11, 1):
break
else:
print('Please choose a number between 1 and 10.')
continue
except ValueError:
print ('Please choose a number between 1-10.')
continue
self.lemonade += lemonade
self.cash -= lemonade * (float(self.lemonade_price) / 100)
self.day += 1
self.weather = random.randrange(50, 100)
self.lemonade_price = random.randrange(1, 10)
print('You made ' + str(lemonade) + ' cups of lemonade! ')
def sell_lemonade(self):
""" Sell lemonade that you have made previously. Bad weather and/or high price will discount net demand. """
while True:
try:
price = int(raw_input('How many cents will you charge for a cup of lemonade? (0-100) '))
if price in range(0, 101):
break
else:
print('Please choose a number between 1 and 100')
continue
except ValueError, e:
print ('Please choose a number between 1 and 100.')
continue
cups = random.randrange(1, 101) # without heat or price factors, will sell 1-100 cups per day
price_factor = float(100 - price) / 100 # 10% less demand for each ten cent price increase
heat_factor = 1 - (((100 - self.weather) * 2) / float(100)) # 20% less demand for each 10 degrees below 100
if price == 0:
self.lemonade = 0 # If you set price to zero, all your lemonade sells, for nothing.
print('All of your lemonade sold for nothing because you set the price to zero.')
self.day += 1
self.weather = random.randrange(50, 100)
self.lemonade_price = random.randrange(1, 10)
demand = int(round(cups * price_factor * heat_factor))
if demand > self.lemonade:
print(
'You only have ' + str(self.lemonade) + ' cups of lemonade, but there was demand for ' + str(
demand) + '.')
demand = self.lemonade
revenue = demand * round((float(price) / 100), 2)
self.lemonade -= demand
self.cash += revenue
self.day += 1
self.weather = random.randrange(50, 100)
self.lemonade_price = random.randrange(1, 10)
print('You sold ' + str(demand) + ' cup(s) of lemonade and earned $' + str(revenue) + ' dollars! ')
def display_data(self, name):
""" Display all data for the lemonade stand."""
if self.day == 0:
print(' Welcome ' + name + '! ')
print('Day: ' + str(self.day))
print('Weather: ' + str(self.weather))
print('Cash: $' + str(self.cash))
print('Lemonade: ' + str(self.lemonade))
print('Cost to make Lemonade: $' + str(float(self.lemonade_price) / 100))
print('============================' + ' ')
def main():
""" Create new LemonadeStand object and play game, or exit.
"""
choice = ''
while choice not in ['y', 'n']:
choice = raw_input('Create a new lemonade stand? (y/n) ')
if choice == 'y':
name = raw_input('Hi friend. What is your name? ')
stand = LemonadeStand()
stand.display_data(name)
while True:
choice = raw_input('Enter 1 to make lemonade. Enter 2 to sell lemonade. 3 to quit. ')
if choice == '1':
stand.make_lemonade()
stand.display_data(name)
continue
elif choice == '2':
stand.sell_lemonade()
stand.display_data(name)
continue
elif choice == '3':
break
else:
print('You must choose either 1 or 2 or 3.')
continue
elif choice == 'n':
print('Goodbye!')
return
main()
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.