Question

In: Computer Science

put a loop around the main module that will ask the user if they want to...

put a loop around the main module that will ask the user if they want to run the program again with another week of lemonade and cookie sales.

def main():
  
# constants given
CUP_COST= .05
LEMONADE_MIX_OZ_COST =.10
COSTOFCOOKIES = .11
COOKIESALE = .25


#inputs
numberOfCupsUsed=int(input('Enter the number of cups used this week '))
ouncesOfMixUsed=int(input('Enter ounces of Lemonade mix used '))
salesForWeekLemonade=float(input('Enter total Lemonade sales for the week $'))
cookiesSoldForWeek = int(input("Enter number of cookies sold for the week: "))
  
#processing
costOfCups = numberOfCupsUsed * CUP_COST
costOfMix = ouncesOfMixUsed * LEMONADE_MIX_OZ_COST
salesTaxLemonade = computeSalesTax(salesForWeekLemonade)
profitLemonade = salesForWeekLemonade - costOfCups - costOfMix - salesTaxLemonade
costcookies = COSTOFCOOKIES * cookiesSoldForWeek
saleofcookies = COOKIESALE * cookiesSoldForWeek
salesTaxCookies = computeSalesTax(saleofcookies)
profitcookie = saleofcookies - costcookies - salesTaxCookies
  
#output
print('lemonade sales for week is...... $',salesForWeekLemonade,sep="")
print('lemonade sales Tax is........... $',salesTaxLemonade,sep="")
print('lemonade cost of cups is ....... $',costOfCups,sep="")
print('lemonade cost of mix is......... $',costOfMix,sep="")
print('lemonade profit for week is..... $',profitLemonade,sep="")
print ("Number of cookies sold", cookiesSoldForWeek)
print("cost of cookies sold", costcookies)
print("sale amount of cookies",saleofcookies)
print("profit of selling cookies", profitcookie)
print('total profit from lemonade and cookies is',profitcookie + profitLemonade)
if profitcookie > profitLemonade:
print("cookies sold more than lemonade")
elif profitLemonade > profitcookie:
print("lemonade sold more than cookies")
else:
print("Both lemonade and cookies are equal")

def computeSalesTax(sales):
SALES_TAX_RATE=.07
taxes = SALES_TAX_RATE * sales
return taxes

main()

Solutions

Expert Solution

def main():
# constants given
CUP_COST= .05
LEMONADE_MIX_OZ_COST =.10
COSTOFCOOKIES = .11
COOKIESALE = .25
  
again = "y"
while again.lower()!="n":
#inputs
numberOfCupsUsed=int(input('Enter the number of cups used this week '))
ouncesOfMixUsed=int(input('Enter ounces of Lemonade mix used '))
salesForWeekLemonade=float(input('Enter total Lemonade sales for the week $'))
cookiesSoldForWeek = int(input("Enter number of cookies sold for the week: "))
  
#processing
costOfCups = numberOfCupsUsed * CUP_COST
costOfMix = ouncesOfMixUsed * LEMONADE_MIX_OZ_COST
salesTaxLemonade = computeSalesTax(salesForWeekLemonade)
profitLemonade = salesForWeekLemonade - costOfCups - costOfMix - salesTaxLemonade
costcookies = COSTOFCOOKIES * cookiesSoldForWeek
saleofcookies = COOKIESALE * cookiesSoldForWeek
salesTaxCookies = computeSalesTax(saleofcookies)
profitcookie = saleofcookies - costcookies - salesTaxCookies
  
#output
print('lemonade sales for week is...... $',salesForWeekLemonade,sep="")
print('lemonade sales Tax is........... $',salesTaxLemonade,sep="")
print('lemonade cost of cups is ....... $',costOfCups,sep="")
print('lemonade cost of mix is......... $',costOfMix,sep="")
print('lemonade profit for week is..... $',profitLemonade,sep="")
print ("Number of cookies sold", cookiesSoldForWeek)
print("cost of cookies sold", costcookies)
print("sale amount of cookies",saleofcookies)
print("profit of selling cookies", profitcookie)
print('total profit from lemonade and cookies is',profitcookie + profitLemonade)
if profitcookie > profitLemonade:
print("cookies sold more than lemonade")
elif profitLemonade > profitcookie:
print("lemonade sold more than cookies")
else:
print("Both lemonade and cookies are equal")
again=input("Do you want to run again for another week? (y/n): ")

def computeSalesTax(sales):
SALES_TAX_RATE=.07
taxes = SALES_TAX_RATE * sales
return taxes

main()


Related Solutions

Use a for loop to ask a user to enter the grades of 5 courses. The...
Use a for loop to ask a user to enter the grades of 5 courses. The user should enter character values, e.g., A. Calculate the GPA of the user Hint: Convert the character values entered to numerals, e.g., A to 4 c programming help me please
Ask the user how many days that they collected gems. A loop you write should loop...
Ask the user how many days that they collected gems. A loop you write should loop how many days the user enters. If the user enters 5 days, then the loop should loop 5 times to collect the data from each day. So, each loop iteration represents a day. In each loop iteration, ask the user how many gems they collected that day. After the loop finishes gathering the data for each day, calculate the total and average gems collected....
Write a program that uses a while loop with a priming read to ask the user...
Write a program that uses a while loop with a priming read to ask the user to input a set positive integers. As long as the user enters a number greater than -1, the program should accumulate the total, keep track of the number of numbers being entered and then calculate the average of the set of numbers after the user enters a -1. This is a sentinel controlled-loop. Here is what a sample run should look like: Enter the...
Write a Python program that has a loop to continuously ask the user for a number,...
Write a Python program that has a loop to continuously ask the user for a number, terminating the loop when the number entered is -1. Inside the loop, 1.) display one asterisk(*) if the number is 1, 2.) two asterisk(**) if the number is 2 and 3.) "OTHER" if the number is any other number.
.......Subject Java..... main() main() will ask the user for input and then call functions to do...
.......Subject Java..... main() main() will ask the user for input and then call functions to do calculations. The calculations will be returned to main() where they will be printed out. First function Create a function named computeBill that receives on parameter. It receives the price of an item. It will then add 8.25% sales tax to this and return the total due back to main(). Second function Create another function named computeBill that receives 2 parameters. It will receive the...
in java Write a while loop to ask the user to type number of hours(double) they...
in java Write a while loop to ask the user to type number of hours(double) they work per day. Calculate and print the salary for each valid input. If number of hours is greater than or equal to 0 and less than 5, then:  salary = numberofhours * 5, loop continues, the user can type another number If number of hours is greater or equal to 5, and less than 10, then: salary = numberofours * 8, loop continues, the user...
Write a while loop to ask the user to type number of hours(double) they work per...
Write a while loop to ask the user to type number of hours(double) they work per day. Calculate and print the salary for each valid input. If number of hours is greater than 0 and less than 5, then:  salary = numberofhours * 12, loop continues, the user can type another number If number of hours is greater or equal to 5, and less than 12, then: salary = numberofours * 14, loop continues, the user can type another number If...
Suppose you are a gas user, such as a chemical company, and want to put a...
Suppose you are a gas user, such as a chemical company, and want to put a ceiling on the price you will have to pay for gas in 3 months by longing a call with K=$5.00. To offset (approximately) the cost of the call, you short a put with K=$4.20. Calculate and graph the net price you will pay for your gas 3 months later when gas prices are $3.80, $4.00, $4.20, ....$5.20 including the future value of the option...
Ask the user for a filename, then ask the user for a line of text. Write...
Ask the user for a filename, then ask the user for a line of text. Write the line of text the filename specified by the user. The filename may be absolute or relative to the project directory.
Flowchart + Python. Ask the user for a value. Then, ask the user for the number...
Flowchart + Python. Ask the user for a value. Then, ask the user for the number of expressions of that value. Use While Loops to make a program. So then, it should be so that 5 expressions for the value 9 would be: 9 * 1 = 9 9 * 2 = 18 9 * 3 = 27 9 * 4 = 36 9 * 5 = 45 Flowcharts and Python Code. Not just Python code. I cannot read handwriting....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT