Fat Percentage Calculator
Create an application that allows the user to enter the number of calories and fat grams in a food. The application should display the percentage of the 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 the food is low in fat. (Display the message in a label or a message box.) The application’s form should appear similar to the one shown in Figure 1.
One gram of fat has 9 Calories, so:
Calories from fat = fat grams * 9
The percentage of calories from fat can be calculated as: Percentage of calories from fat = Calories from fat / total calories
Figure 1

Input validation: Make sure the number of calories and fat grams are numeric, and 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 indicating that either the calories or fat grams were incorrectly entered.
Use the following test data to determine if the application is calculating properly:
Calories and Fat | Percentage Fat |
200 calories, 8 fat grams 150 calories 2 fat grams 500 calories, 30 fat grams | Percentage of calories from fat: 36% Percentage of calories from fat: 12% (a low-fat food) Percentage of calories from fat: 54% |
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.