programming forums Java Java JSRs Mobile Certification Databases Caching Books Engineering OS Languages Paradigms IDEs Build Tools Frameworks Products This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Sheriffs:
Saloon Keepers:
Bartenders:

# Fat Grams Calculator project

Matt Kroeger
Greenhorn
Posts: 2
I could use some help on this please!

Fat Gram calculator

Design a program that asks for the number of fat grams and calories in a food item. Validate the input as follows:

- Make sure the number of fat grams and calories are not less than 0.
- According to nutritional formulats, the number of calories cannot exceed fat grams * 9. Make sure the number of calories entered is not greater than fat grams * 9.

Once correct data has been entered, the program should calculate and display the percentage of calories that come from fat. Use the following formula: Percentage of calories from fat = (Fat grams * 9) / calories.

Some nutritionists classify a food as "low fat" if less than 30 percent of its calories come from fat. If the results of this formula are less than 0.3, the program should display a message indicating the food is low in fat.

Seems I am having issues with the while statement or I have this all wrong. I would truly appreciate some suggestions, troubleshooting steps, and resolution to this problem. Please see file attached.

I also seem to be having issues posting my entire project in this topic :S

(Any suggestion as to do that would also be appreciated)

Matt Kroeger
Greenhorn
Posts: 2
• 1
Thank you much appreciated still new at this!

Bear Bibeault
Author and ninkuma
Marshal
Posts: 66306
152
• 1
No problem.

Just glancing over your code, you have a lot of extraneous braces, and some semi-colons in incorrect places. Remember that a semi-colon ends a statement, so carefully consider what putting one at the end of a while statement means.

Clean up the braces, check the semi-colons, and be sure to use indentation correctly. It may seem like a small thing, but proper indentation is a powerful tool for making sure that your program structure is correct.