Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

For my Java course: The Harris-Benedict equation estimates number of calories yo

ID: 3663704 • Letter: F

Question

For my Java course: The Harris-Benedict equation estimates number of calories your body needs to maintain your weight with no exercise. This is your BMR. The formula for a woman to maintain her weight: BMR = 655+(4.3 * weight in pounds) + (4.7 * height in inches) - (4.7 * age in years) For a man: BMR = 66 + (6.3 * weight in pounds) + (12.9 * height in inches) - (6.8 * age in years) Typical chocolate bar will contain around 230 calories. Write program allowing user to input his or her weight in pounds, height in inches, age in years, and the character M or F for female. Program should then output the number of chocolate bars that should be consumed to maintain one's weight for the appropriate sex of the specified weight, height, and age. (Include an if statement).

Explanation / Answer

import java.util.*;
class MyClassM
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
double weight;
double height;
double age;
double bmr=0;
char gender;
System.out.println("Enter Weight in pounds");
weight = sc.nextDouble();
System.out.println("Enter the height in inches");
height = sc.nextDouble();
System.out.println("Enter your age: ");
age = sc.nextDouble();
System.out.println("Enter your Gender: ");   
gender = sc.next().charAt(0);
if('m' == gender || 'M' == gender)
{
bmr = 66 + (6.3 * weight) + (12.9 * height) - (6.8 * age);   
}
else if('f' == gender || 'F' == gender)
{
bmr = 655 + (4.3 * weight) + (4.7 * height) - (4.7 * age);
}
else
{
System.out.println("Not a Human");
}
final double numbars = bmr / 230;
System.out.printf("The person with the entered metrics is allowed to consume %.2f bars of chocolate.",numbars);
}
}

/* IF any problem with code do comment */