## BMI Calculator Using Java In this article, I’m going to teach the concept of the “BMI Calculator Using Java” program. Let’s start the article to make a BMI calculator.

Contents

## BMI

BMI stands for Body Mass Index. We can calculate our body fatness using the BMI calculator. The formula for calculating the BMI will show below for your reference.

``BMI = weight / (height * height)``

BMI is based on our height and weight. We can check our body weight will be either underweight or normal or overweight to analyze our health by applying the values of height (in meters) and weight (in kilogram) into the formula.

## BMI Calculator Using Java

This is the basic program to make a BMI calculator using java here.

``````import java.util.Scanner;
public class Example {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
System.out.print("Input weight in kilogram: ");
double weight = sc.nextDouble();
System.out.print("\nInput height in meters: ");
double height = sc.nextDouble();
double BMI = weight / (height * height);
System.out.print("\nThe Body Mass Index (BMI) is " + BMI + " kg/m2");
}
}``````

## Source Code Explanation

Firstly, We need to import the java.util.scanner() class into this program. After running this program, The program asks you to enter the input values of height (in meters) and weight (in kilogram) using the new scanner() class.

Later, The BMI output will be calculated using the formula and the output will display on the screen using the system.out.printIn() function.

`Read Also : Java program to Make Simple Calculator`

## Note

You can also create BMI Calculator Using JavaScript. If you want to learn then click on the link to learn about it.

## Output

The output will be shown below for your reference.

``````Input weight in kilogram: 90
Input height in meters: 1.8
The Body Mass Index (BMI) is 27.777777777777775 kg/m2``````

## Final Words

You can create an amazing BMI calculator using the java program. I hope this article helps you. If any error occurs please contact us via the comment section. Share this article with others Java developers via social networks.

### Manoj S

Hi, I'm Manoj working as a part-time blogger in Coding Diksha. Here, I post about programming to help developers.