Java-Projects-Collections
Java-Projects-Collections copied to clipboard
Update CalorieCalculator.java
Key Changes:
- Constants: Used constants to store BMR coefficients and activity multipliers for readability and easier maintenance.
- Input Validation: Added validation for user input (gender, age, weight, height, and activity level) to ensure they are correct and meaningful.
- Better Error Handling: If invalid data is entered (like a non-integer for age or weight), the program will prompt the user to enter valid data again.
- Cleaner Output Formatting: The output is formatted to remove unnecessary decimals and display numbers cleanly.
- Helper Methods: Encapsulated logic for input validation and BMR/Calorie calculation into separate methods for better code organization and reusability.