Question
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started