Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need solved for C++ Write a program that asks the user for three pieces of data: the name of a food item (a string value),

Need solved for C++
image text in transcribed
Write a program that asks the user for three pieces of data: the name of a food item (a string value), the number of calories and the number of grams of fat in the item. The program should display the percentage of calories that come from fat. If the calories from fat are less than 33 percent of the total calories of the food, it should display a message indicating that the food is low in fat. If the percentage is equal to or higher than 33 percent, the message should indicate that the food is high in fat. One gram of fat has 10 calories, so calories from fat = fat grams * 10 The percentage of calories from fat can be calculated as Calories from fat / total calories An example of output with the following input values: name of food: hamburger total calories: 1000 Grams of fat: 40 might be: A hamburger with 1000 calories and 40 grams includes 400 fat calories ( 40.0%), making this food high in fat Input validation: The program should make sure that the number of calorios is greater than 0 , the number of fat grams is 0 or more, and the number of calories from fat is not greater than the number of calonies input

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Conceptual Database Design An Entity Relationship Approach

Authors: Carol Batini, Stefano Ceri, Shamkant B. Navathe

1st Edition

0805302441, 978-0805302448

More Books

Students also viewed these Databases questions