Question: Party budget planning - complex Prompt the user to enter their current budget and the number of people who need to share a meal. You are ordering food from a restaurant that has two menu items: Tacos $4 Empanadas $3 Calculate and print out all the options of meals where the budget is used entirely(where possible) and each person has an equal number of items to eat. They may eat different things, but everyone gets the same number of food items, e.g. 2 tacos or 1 empanada and 1 taco or 2 empanadas. Hints: Here are some things that might help you in your solution. If total items purchased does not equally divide by the number of diners, then abandon that combination. It may help to calculate the max number of empanadas that the budget can buy and also the max number of tacos that the budget could buy. These can be thought of as upper bounds in your loops. In your solution, keep track of items per person Also, keep track of total number of viable solutions, as that might help you determine when there is no solution. My solution is printing "You cannot buy a meal with these options." multiple times even when it is possible to buy a meal. Also my solution does show "Meal options:" before printing all of the alternatives. I've attached the outcome that the program should be displaying and my current code.
Question: Party budget planning - complex
Prompt the user to enter their current budget and the number of people who need to share a meal.
You are ordering food from a restaurant that has two menu items:
-
Tacos $4
-
Empanadas $3
Calculate and print out all the options of meals where the budget is used entirely(where possible) and each person has an equal number of items to eat. They may eat different things, but everyone gets the same number of food items, e.g. 2 tacos or 1 empanada and 1 taco or 2 empanadas.
Hints: Here are some things that might help you in your solution.
- If total items purchased does not equally divide by the number of diners, then abandon that combination.
- It may help to calculate the max number of empanadas that the budget can buy and also the max number of tacos that the budget could buy. These can be thought of as upper bounds in your loops.
- In your solution, keep track of items per person
- Also, keep track of total number of viable solutions, as that might help you determine when there is no solution.
My solution is printing "You cannot buy a meal with these options." multiple times even when it is possible to buy a meal. Also my solution does show "Meal options:" before printing all of the alternatives.
I've attached the outcome that the program should be displaying and my current code.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images