# Exercise 3.6 — Health Application: BMI

Java program ComputeAndInterpretBMI.java, to let the user enter weight, feet, and inches and calculate and interpret the user BMI whether underweight, normal, overweight or obese.

```/**
*
* @Author: Aghatise Osazuwa
* Website: www.cscprogrammingtutorials.com
*/

import java.util.Scanner;

public class ComputeAndInterpretBMI {
public static void main (String [] args) {
Scanner input = new Scanner(System.in);
//Prompt the user to enter weight in pounds
System.out.print("Enter weight in pounds: ");
double weight = input.nextDouble();
//Prompt the user to enter height in feet and inches
System.out.print("Enter feet: ");
double feet = input.nextDouble();
System.out.print("Enter inches: ");
double inches = input.nextDouble();
double height = (feet * 12) + inches;
final double KILOGRAMS_PER_POUND = 0.45359237; // Constant
final double METERS_PER_INCH = 0.0254; // Constant
//Compute BMI
double weightInKilograms = weight * KILOGRAMS_PER_POUND;
double heightInMeters = height * METERS_PER_INCH;
double bmi = weightInKilograms / (heightInMeters * heightInMeters);
// Display result
System.out.println("BMI is " + bmi);
if (bmi < 18.5) {
System.out.println("Underweight");
} else if (bmi < 25) {
System.out.println("Normal");
} else if (bmi < 30) {
System.out.println("Overweight");
} else {
System.out.println("Obese");
}
}
}
```
 Sample run
Click here to see other solutions to Introduction to Java Programming.

#### Post a Comment

DISCLAIMER: Opinions expressed in comments are those of the comment writers alone and does not reflect or represent the views of the post author. We reserve the right to delete any post deemed inappropriate or offensive and/or spammy. Please do not use abusive words/hate speech.

I Appreciate your valuable Feedback. So, Please DO NOT SPAM - Spam comments will be deleted immediately.

Don't use brand name in name field and you're not allowed to use links in comments unless it's necessary. Such comments will be removed immediately. To get notified of replies or follow-up comments, click the box next to notify me.

Thanks.