Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Design a program that asks for the number of fat grams and calories in a food item. Validate the input as follows: - Make sure

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 are 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:

Percentage of calories from fat = (fat grams x 9) / calories

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

Step by Step Solution

3.44 Rating (157 Votes )

There are 3 Steps involved in it

Step: 1

include include using namespace std void main declare variables to store user in... 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

Statistics For Business And Economics

Authors: Paul Newbold, William Carlson, Betty Thorne

8th Edition

0132745658, 978-0132745659

More Books

Students also viewed these Operating System questions

Question

The High Cost of Organizational Change.

Answered: 1 week ago

Question

What is your theoretical orientation? (For Applied Programs Only)

Answered: 1 week ago

Question

Does it come in waves? How often?

Answered: 1 week ago