You are tasked to provide a Fat Gram Calculator program for a local Weight Loss Center....

70.2K

Verified Solution

Question

Programming

You are tasked to provide a Fat Gram Calculator program for alocal Weight Loss Center. The program should ask the user for thename of a food item, the number of calories and the number of fatgrams in the item. The program should display the percentage ofcalories that come from fat. If the calories from fat are less than30 percent of the total calories of the food, it should display amessage indicating that the food is low in fat. If the percentageis equal to or higher than 30 percent the message should indicatethat the food is high in fat.

One gram of fat has 9 calories, so
          caloriesfrom fat = fat grams * 9

The percentage of calories from fat can be calculated as
         Percent Fat =Calories from fat / total calories

Input validation: The program should make sure that thenumber of calories is greater than 0, the number of fat grams is 0or more, and the number of calories from fat is not greater thanthe number of calories input.

Answer & Explanation Solved by verified expert
3.6 Ratings (533 Votes)
codeimport java utilimport javautilScannerdefine a class fat gram calculatorclass Mainmain functionpublic    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students