program4_1.py Write a program that prompts a dieter to enter in their caloric budget (as an integer) for the week. After accepting and storing that value, use a while loop to accept and process the caloric value for each meal (entered as an integer value). Within the while loop keep a running total of the caloric values of the meals entered and a count of the meals entered. Terminate the while loop when the dieter enters 0. After the while loop ends, print the count of meals entered and print a message (follow the examples in the example outputs) indicating whether the dieter's caloric total intake was at, above, or below their caloric budget. Printed output messages will vary based on input but related output should be formatted as in the example outputs. The ellipsis is being used to represent missing values that your program should also generate.

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter5: Looping
Section: Chapter Questions
Problem 7RQ
icon
Related questions
Question

program4_1.py
Write a program that prompts a dieter to enter in their caloric budget (as an integer) for the week. After accepting and storing that value, use a while loop to accept and process the caloric value for each meal (entered as an integer value). Within the while loop keep a running total of the caloric values of the meals entered and a count of the meals entered. Terminate the while loop when the dieter enters 0. After the while loop ends, print the count of meals entered and print a message (follow the examples in the example outputs) indicating whether the dieter's caloric total intake was at, above, or below their caloric budget.

Printed output messages will vary based on input but related output should be formatted as in the example outputs. The ellipsis is being used to represent missing values that your program should also generate.

 

Expert Solution
Step 1

The algorithm of the code is given below:-

1. Print a statement asking the user to enter their caloric budget for the week.
2. Set a variable, caloric_budget, equal to the user's input.
3. Set a variable, caloric_total, equal to 0.
4. Set a variable, meal_count, equal to 0.
5. Create a while loop that runs while meal_calories is not equal to 0.
6. Print a statement asking the user to enter the caloric value of the meal.
7. Set a variable, meal_calories, equal to the user's input.
8. If meal_calories is equal to 0, break out of the loop.
9. Otherwise, add meal_calories to caloric_total and increment meal_count by 1.
10. Print a statement showing the user how many meals they entered and the total calorie value.
11. If caloric_total is above caloric_budget, print a statement saying that the calorie budget is above the caloric intake.
12. If caloric_total is below caloric_budget, print a statement saying that the calorie budget is below the caloric intake.
13. If caloric_total is equal to caloric_budget, print a statement saying that the calorie budget is equal to the caloric intake.

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Types of Loop
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr