Fat Gram Calculator 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...



Fat Gram Calculator


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 percent of the total calories of the food, it should also display a message indicating


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: The program should make sure that the number of calories 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 total number of calories.



May 26, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here