Question: I was wondering how I could program this to end the loop when both variables are = 0 so it will stop calling the loop



I was wondering how I could program this to end the loop when both variables are = 0 so it will stop calling the loop and restarting it.
Homework 1: The Yorktown theatre has 300 hall seats and 100 mezzanine seats. A hall seat costs $10 for an adult and $7 for a child. A mezzanine seat costs $8 for an adult and $5 for a child. Write a program to REPEATEDLY prompt the user to enter the required seating (1 for hall, 2 for mezzanine), the number of adults and children in the party, and the print out a receipt and the number of remaining seats in Hall and Mezzanine. An order will be refused if there are not enough seats in the required area. The program loops until there are no more seats in either hall or mezzanine. Sample interaction: Enter 1 for Hall and 2 for Mezzanine: 1 Number of adults? 2 Number of children? 3 Great, You got 2 adult tickets for $20 and 3 child tickets for $21 so your total is $41 Remaining seats: Hall 295 Mezzanine 100 Enter 1 for Hall and 2 for Mezzanine: 2 Number of adults? 1 Number of children? 4 Great, You got 1 adult tickets for $8 and 4 child tickets for $20 so your total is $28 Remaining seats: Hall 295 Mezzanine 95 def main(): numberofSeatHall - 300 numberofSeatMezzanine = 100 priceHalladult - 10 pricelallchildren - 7 priceMezzadult - 8 priceMezzchildren -5 while True: flag-0 HallorMezzanine = int(input("Enter 1 for Hall and 2 for Mezzanine)) if(HallorMezzanine !-1 and HallOrMezzanine 1-2 ): print("Please enter Correct details") break Numberofadult- int(input("Number of adults? ")) #reading number of adults Numberofchildren - int(input("Number of children? ") Breading number of children print() print() if(Hal10rMezzanine 1): if(Numberofadult-Numberofchildren > numberofSeatHall): print("Not enough seats") flag-1 if (flag -- 0) numberofSeatHall--(Number0fadult-Number0fchildren) costChildren Numberofchildren priceHallchildren calculating cost for children costAdult - Numberofadult*priceHalladult scalculating cost for adult print("Great you got ",Numberofadult, adult tickets for $",costAdult, "and ",Numberofchildren, child tickets for $, costChildren, "so your total cost is $",costChildren-costAdult) elif(Hal10rMezzanine 2): if(Numberofadult+Numberofchildren > numberofSeatMezzanine): print("Not enough seats") flag-1 if(flag 0): numberofSeatMezzanine--(Numberofadult+Numberofchildren) costChildren - Numberofchildren*priceMezzchildren #calculating cost for children costAdult - Numberofadult*priceMezzadult scalculating cost for adult costChildren. sn vnur total.cost is 5.costChildrenerostAdult) Ln: 62 Col: 8 nrint("Great vou ont" Numhernfndult adult tickets for $costAdult "andNumherofchil deen" child tickets for "homework1 CS112.py -/Users/johnpatrizzi/Documents/homework1 CS112.py (3.7.4) O * * 85% Thu Jan 23 13:32 C HallOrMezzanine = int(input("Enter 1 for Hall and 2 tor Mezzanne )) if (HallOrMezzanine !-1 and HallOrMezzanine 1-2 ): print("Please enter Correct details") break Numberofadult - int(input("Number of adults? ")) areading number of adults Numberof chi ldren- intCinput("Number of children? )) #reading number of children print() print) if(Hall0rMezzanine 1): E(Numberofadult-Numberofchildren > numberofSeatHall): print("Not enough seats") flag-1 if (flag - 0): numberofSeatHall-=(Numberofadult+Numberofchi tdren) costChildren - Numberofchildren priceHallchildren scalculating cost for children costAdult - Numberofadult*pricelalladult #calculating cost for adult print("Great you got ",Numberofadult," adult tickets for $",costAdult, "and ", Numberofchildren," child tickets for S",costChildren, "so your total cost is S",costChildren+costAdult) elif(HallOrMezzanine -- 2): if(Numberofadult Numberofchildren > numberofSeatMezzanine): print("Not enough seats") flag-1 if(flag -- 0): numberofSeatMezzanine--(Numberofadult+Numberofchildren) costChildren - Numberofchildren priceMezzchildren #calculating cost for children costAdult - Numberofadult*priceMezzadult #calculating cost for adult print("Great you got ",Numberofadult," adult tickets for S",costAdult, "and ", Numberofchildren," child tickets for $", costChildren, "so your total cost is $, costChildrenecostAdult) print(" Remaining seats : Hall, numberofSeotHall," Mezzanine ",numberofSeatMezzanine, " ") #display renaing if (numberofSeatMezzaninece or numberofSeatHallc0): sif one of two O continue to ask continue if(numberofSeatMezzanine-0 and numberofSeatHall--0): #if both e end loop break print("No more seats available") main) Ln: 62 Col: 8 PC 23
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
