Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Must be done in Visual Studio Write a program that asks for the number of calories and fat grams in a food. The program should

Must be done in Visual Studio

Write a program that asks for the number of calories and fat grams in a food. The program should display the percentage of calories that come from fat. If the calories from fat are less than 30% of the total calories of the food, it should also display a message indicating that the food is low in fat.

One gram of fat has 9 calories, so

Calories from fat = fat grams * 9

The percentage of calories from fat can be calculated as

Calories from fat / total calories

Input Validation: Make sure the number of calories and fat grams are not less than 0. Also the number of calories from fat cannot be greater than the total number of calories. If that happens, display an error message indication that either the calories or fat grams were incorrectly entered.

Give an explanation at the beginning of the program defining calories and fat content, what the program will calculate and what a valid entry would be.

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

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

9th Edition

0135188148, 978-0135188149, 9781642087611

More Books

Students also viewed these Databases questions

Question

Why is the System Build Process an iterative process?

Answered: 1 week ago