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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education