Design a class with a method that stores the number of calories and fat grams in a food item. The class should have a method that returns the percentage of the calories that come from fat. one gram of fat has 9 calories, so: fat grams * 9. the percentage of calories from fat can be calculated as: calories from fat / total calories.
demonstrate the class in a program that asks the user for fat grams .if the user enters a number for the fat grams that calculates to contain more calories than the total number of calories for the food item, the program should display an error message indicating that the two input numbers are invalid and prompt for those inputs again, or at least prompt for the fat grams again.
Answers
Answered by
0
Answer:
your question is so big I couldn't solve
Similar questions