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.
Introduction to Java Programing Using Loop Create a simple calculator program using loop Ask user to...
Introduction to Java Programing Using Loop Create a simple calculator program using loop Ask user to input two numbers using scanner class Print the instruction of the menu for the calculator program Ask user to press 0 to Quit Ask user to press 1 to Add Ask user to press 2 to Substract Ask user to press 3 to Multiply Ask user to press 4 to Divide Perform correct calcuation based on user inputs and print the result Print error...
.......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...
C++ while loop Exercise Write a program that continues to ask the user to enter any...
C++ while loop Exercise Write a program that continues to ask the user to enter any set of numbers, until the user enters the number -1. Then display the total sum of numbers entered and their average. (note that you need to define a counter that counts how many numbers so the average = (sum/n) where n is your counter total. #include <iostream> using namespace std; int main() { int number, n=0, sum=0; cout << "Enter a number to start...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT