Shivam171 / Diet-Adviser

πŸ” Diet Adviser πŸ§‘β€βš•οΈ | Java

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

πŸ§‘β€βš•οΈ Diet-Adviser πŸ”

Write a program in java where doctor is giving advice to patient about how to maintain our body which type of food we should take. For that doctor asks for the number of calories and fat grams in a food. Then it will 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. Consider one gram of fat has 5 calories.

Workflow

Here, we first import the Scanner class to take input from the user. Then we prompt the user to enter the number of calories and fat grams in the food. We calculate the number of calories from fat by multiplying the number of fat grams by 5 (since one gram of fat has 5 calories).

Then we calculate the percentage of calories that come from fat by dividing the number of fat calories by the total number of calories, and multiplying by 100. We use printf to format the output to two decimal places.

Finally, we check if the percentage of calories from fat is less than 30%, and if it is, we display a message indicating that the food is low in fat.

Output:

2023-02-20_19-24

Note: There are some more changes need to be done in this, I'll update it soon.

About

πŸ” Diet Adviser πŸ§‘β€βš•οΈ | Java


Languages

Language:Java 100.0%