I need the program to print the line "Meal options:" only when there is enough money.

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter4: Making Decisions
Section: Chapter Questions
Problem 18RQ
icon
Related questions
Question
I need the program to print the line "Meal options:" only when there is enough money. 
 
def get_possible_meals(budget, num_persons):
tacos_cost = 4
empanandas_cost = 3
max_tacos = budget // tacos_cost
max_empanadas = budget // empanandas_cost
feasible = False
print("\nMeal options:")
for num_tacos in range (max_empanadas + 1):
num_empanadas = (budget - num_tacos * tacos_cost) // empanandas_cost
if num_empanadas > 0andnot (num_empanadas + num_tacos) % num_persons:
feasible = True
total_cost = num_tacos * tacos_cost + num_empanadas * empanandas_cost
change = budget - total_cost
print(f'${total_cost} buys {num_empanadas} empanadas and {num_tacos} tacos with ${change} change. {(num_empanadas + num_tacos) // num_persons} items per person.')
ifnot feasible:
print(f'You cannot buy a meal with these options.')

def main():
budget = int(input('Enter budget for meal: $'))
num_people = int(input('How many people are eating: '))
get_possible_meals(budget, num_people)
if __name__ == '__main__':
main()
Enter budget for meal: $100
How many people are eating: 6
Meal options:
$98 buys 22 empanadas and 8 tacos with $2 change.
5 items per person.
$99 buys 21 empanadas and 9 tacos with $1 change.
5 items per person.
$100 buys 20 empanadas and 10 tacos without change. 5 items per person.
or
Enter budget for meal: $33
How many people are eating: 15
You cannot buy a meal with these options.
Transcribed Image Text:Enter budget for meal: $100 How many people are eating: 6 Meal options: $98 buys 22 empanadas and 8 tacos with $2 change. 5 items per person. $99 buys 21 empanadas and 9 tacos with $1 change. 5 items per person. $100 buys 20 empanadas and 10 tacos without change. 5 items per person. or Enter budget for meal: $33 How many people are eating: 15 You cannot buy a meal with these options.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
Computer Science
ISBN:
9780357392676
Author:
FREUND, Steven
Publisher:
CENGAGE L