Starting Out with Programming Logic and Design (4th Edition)
Starting Out with Programming Logic and Design (4th Edition)
4th Edition
ISBN: 9780133985078
Author: Tony Gaddis
Publisher: PEARSON
bartleby

Concept explainers

bartleby

Videos

Textbook Question
100%
Book Icon
Chapter 7, Problem 3PE

Fat Gram Calculator

Design a program that asks for the number of fat grams and calories in a food item.

Validate the input as follows:

  • Make sure the number of fat grams and calories is not less than 0.
  • According to nutritional formulas, the number of calories cannot exceed fat grams X 9. Make sure that the number of calories entered is not greater than fat grams X 9.

Once correct data has been entered, the program should calculate and display the percentage of calories that come from fat. Use the following formula:

P e r c e n t a g e   o f   c a l o r i e s   f r o m   f a t = ( F a t   g r a m s × 9 )   ÷ C a l o r i e s

Some nutritionists classify a food as “low fat” if less than 30 percent of its calories come from fat. If the results of this formula are less than 0.3, the program should display a message indicating the food is low in fat.

Blurred answer
Students have asked these similar questions
Fat Gram Calculator   Design a program that asks for the number of fat grams and calories in a food item. Validate the input as follows:  Make sure the number of fat grams and calories is not less than 0.  According to nutritional formulas, the number of calories cannot exceed fat grams x 9. Make sure that the number of calories entered is not greater than fat grams x 9. Once corrected data has been entered, the program should calculate and display the percentage of calories that come from fat. Use the following formula: Percentage of calories from fat = (Fat grams x 9) / calories ANSWER IN PSEUDOCODE USE ONLY WHILE LOOPS  DO NOT USE MODULES/FUNCTIONS
Fat Gram Calculator   Design a program that asks for the number of fat grams and calories in a food item. Validate the input as follows:  Make sure the number of fat grams and calories is not less than 0.  According to nutritional formulas, the number of calories cannot exceed fat grams x 9. Make sure that the number of calories entered is not greater than fat grams x 9. Once corrected data has been entered, the program should calculate and display the percentage of calories that come from fat. Use the following formula: Percentage of calories from fat = (Fat grams x 9) / calories ANSWER IN PSEUDOCODE
(Science: calculating energy) Write a program that calculates the energy needed to heat water from an initial temperature to a final temperature. Your program should prompt the user to enter the amount of water in kilograms and the initial and final temperatures of the water. The formula to compute the energy is Q = M * (finalTemperature – initialTemperature) * 4184 where M is the weight of water in kilograms, temperatures are in degrees Celsius, and energy Q is measured in joules.

Chapter 7 Solutions

Starting Out with Programming Logic and Design (4th Edition)

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
The size, shape, color and weight of an object are considered of the objects class.

Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)

A loop that is inside another is called a(n) ________ loop.

Starting Out with C++: Early Objects (9th Edition)

What is hardware?

Starting out with Visual C# (4th Edition)

Describe the limitation of static methods.

Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)

Knowledge Booster
Background pattern image
Computer Science
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
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Python Tutorial #10; Math Functions in Python; Author: Art of Engineer;https://www.youtube.com/watch?v=OviXsGf4qmY;License: Standard YouTube License, CC-BY