5. The Harris-Benedict equation estimates the number of calories your body needs
ID: 3678942 • Letter: 5
Question
5. The Harris-Benedict equation estimates the number of calories your body needs to maintain your weight if you do not exercise. This is called your basal metabolic rate, or BMR. The calories needed of a woman to maintain her weight is: BMR = 655 + (4.3 x weight in pounds) (4.7 x height in inches) (4.7 x age in years) The calories needed of a man to maintain his weight is: BMR = 66 + (6.3 x weight in pounds) + (12.9 x height in inches) (6.8 x age in years) A typical chocolate bar will contain around 230 calories. Write a program that allows the user to input the weight, height, and age. The program should then output the number of chocolate bars that should be consumed to maintain one's weight for both a woman and a man of the inputExplanation / Answer
TestBMR.java
import java.util.Scanner;
public class TestBMR
{
public static void main(String[] args)
{
final int CALORIES_PER_BAR = 230;
Scanner console = new Scanner(System.in);
int gender;
double weight;
double height;
double age;
double bmr;
double bars;
System.out.print("Enter 0 for woman or 1 for man: ");
gender = console.nextInt();
System.out.print("Enter weight in pounds: ");
weight = console.nextDouble();
System.out.print("Enter height in inches: ");
height = console.nextDouble();
System.out.print("Enter age in years: ");
age = console.nextDouble();
if(gender == 0)
{
bmr = 655 + (4.3 * weight) + (4.7 * height) - (4.7 * age);
System.out.println(" Woman's BMR is " + bmr);
}
else // if(gender == 1)
{
bmr = 66 + (6.3 * weight) + (12.9 * height) - (6.8 * age);
System.out.println(" Man's BMR is " + bmr);
}
bars = bmr / CALORIES_PER_BAR;
System.out.printf("%.0f bars of chocolates can be consumed to maintain one's weight.", bars);
}
}
Output:
Enter 0 for woman or 1 for man: 0
Enter weight in pounds: 160
Enter height in inches: 5.1
Enter age in years: 42
Woman's BMR is 1169.57
5 bars of chocolates can be consumed to maintain one's weight.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.