5/16/2017 Need help ASAP programming this lemonade stand game on this website ht
ID: 3840388 • Letter: 5
Question
5/16/2017 Need help ASAP 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 python and all the info I need is listed below that needed to create the program.
what I need to program in python:
introduction to the lemonade stand game
“welcome to my lemonade stand game”
how long would you like to play the game?
in the game, you can play” 7 days 14 days 30 days”
you start the game with $20.00
Temperature
Set the Random temperature for each day the player is playing the game
Weather forecast: hazy, raining, sunny, breeze
next, in the game, you buy inventory/purchasing
how many cups would you like to buy?
25 cups for .97
50 cups for $1.63
100 cups for$ 2.86
How many lemons would you like to buy?
10 for .61
30 for $2.15
75 for $4.10
How many cups of sugar would you buy?
8 for .55
20 for $1.75
48 for $3.36
How many cups of ice would you like to buy?
100 for .98
250 for $2.20
500 for $3.62
before you start the game,
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 %
so how many customers walked away today happy and how many bought your lemonade
PLEASE DO NOT SAY "Insignificant knowledge." LET ME KNOW EXACTLY WHAT NEEDS TO BE ADD IN ORDER TO CREATE PROGRAM.
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.