Java BMI Calculator Program

A BMI calculator helps in calculating Body-Mass Index.

Body Mass Index is a tool or a formula which helps us in knowing whether a person’s body weight is appropriate or not. It measures body weight with respect to the person’s height.

BMI is calculated by dividing a person’s weight in kilograms by square of height in meters.

BMI basically gives an estimate on how healthy our weight is.

According to National Institutes of Health (NIH):

A person with:

  • BMI less than 18.5 is considered underweight.
  • BMI between 18.5 and 24.9 is considered ideal.
  • BMI between 25 and 29.9 is considered overweight.
  • BMI above 30 is considered obese.

Java BMI Calculator Program

BMI.java

import java.util.Scanner;

public class BMI{
public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);

		System.out.print("Enter the weight in kilograms: ");
		double weight = sc.nextDouble();

		System.out.print("\nEnter the height in meters: ");
		double height = sc.nextDouble();

		double BMI = weight / ( height*height );

		System.out.print("\nThe Body Mass Index (BMI) is " + BMI + " kg/m2");
	}
}

Output:

Enter weight in kilograms: 55
Enter height in meters: 1.6
The Body Mass Index (BMI) is 21.484375 kg/m2

Leave a Comment

Your email address will not be published. Required fields are marked *