Question
So this python program is suppose to calculate Farmer Suzy's sales and expenses but I'm running into the issue where the user can choose to
So this python program is suppose to calculate Farmer Suzy's sales and expenses but I'm running into the issue where the user can choose to either put the driving route of the mountain which is 11.75 mi or the driving route of the river which is 7.22 mi. Then you calculate the miles divided by 7.5 mpg of her truck then times the price of $3.199 per gallon. Not sure if I need to use a while loop or a if-else loop. Here is what I have though.
def main(): print("Welcome Farmer Suzy!") total_eggs = int(input("How many eggs did you collect this week?:"))
#Set accumulator for number of errors if user inputs amount #Less than 1 or more than 750 eggs
error_count = 0
#Start the while loop to continue program for valid input
while (total_eggs <= 1 and total_eggs >= 750) and (error_count < 3): error_count += 1 print ("That is not a valid number of eggs! Let's try this again!") total_eggs = int(input("How many eggs did you collect this week?:"))
#Set up if-else loop for error count if error_count == 3: print("Error! Too many invalid inputs! End of program") else: #Get the input data and define each vaiable driving_route = input("What route will you take today?" " Enter M for Mountain or R for River: ") #Create a loop mto determine the calculations for the driving route amountOftoms = int(input("How many pounds of tomatoes did you sell? ")) amount_sweetpotatoes = int(input("How many sweet potatoes did you sell? ")) gallonsOfmilk = int(input("How many gallons of milk did you sell? "))
#Calculate how many cartons are made and how many Suzy keeps suzy_keeps = 24 EggsAfterSuzy = total_eggs - suzy_keeps cartonOfeggs = EggsAfterSuzy // 12 LeftOverEggs = (EggsAfterSuzy % 12)
#Now find Suzy's sales of eggs, veggies, and milk SaleOfEggs = cartonOfeggs * 6 SaleOfVeggies = (amountOftoms * 3.50) + (amount_sweetpotatoes * 1.25) SaleOfMilk = gallonsOfmilk * 11 TotalSales = SaleOfEggs + SaleOfVeggies + SaleOfMilk #Calculate Suzy's expenses of Zach's salary, farmer market fee, maintenance #And mileage then combine the total
ZachsSalary = 15 * 10.50 MarketFee = (SaleOfEggs + SaleOfVeggies) * .01 #Suzy pays $.25 per chicken (25 chickens) for food and pays $.22 #Each one for up keep for a week ChickenCost = (25 *.25) + (25 * .22) #Suzy pays $12 per cow (6 cows) for up keep each week CowCost = 12 * 6 GardenCost = 20
TotalExpenses = ZachsSalary + MarketFee + ChickenCost + CowCost + GardenCost
#Then calculate Suzy's weekly profit and estimate her annual #profit by 52 weeks a year WeeklyProfit = TotalSales - TotalExpenses AnnualProfit = WeeklyProfit * 52
#Now print all variables in the program print("=====================================================================") print(" Here is what your financials look like Suzy: ") print("\tTotal eggs collected \t",total_eggs, "Suzy keeps ",suzy_keeps) print("\tTotal cartons made \t",cartonOfeggs) print("\tSuzy eats \t\t", LeftOverEggs+12, "One dozen + ",LeftOverEggs, "left")
print("Total Expenses: \tZach's Salary \t\t", format(ZachsSalary, '.2f')) print("\tMarket Fee \t\t", format(MarketFee, '.2f')) print("\tChicken Maintenance \t", format(ChickenCost, '.2f')) print("\tCow Maintenance \t", format(CowCost, '.2f')) print("\tGarden Maintenance \t", format(GardenCost, '.2f')) ####print mileage print("\tTotal Expenditure \t")
print("Total Revenue: \tEgg Sales \t\t", format(SaleOfEggs, '.2f')) print("\tVeggie Sales \t\t", format(SaleOfVeggies, '.2f')) print("\tMilk Sales \t\t", format(SaleOfMilk, '.2f')) print("\tTotal Sales \t\t", format(TotalSales, '.2f'))
print("Profits: \tWeekly Profit \t\t", format(WeeklyProfit, '.2f')) print("\tProjected Annual Profit ", format(AnnualProfit, '.2f'))
#End of Main
#Call the main function main()
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started