# How to make a BMI Calculator using Java

## How to make a BMI Calculator using Java

Today I am going to use Java to make a command line application called BMI Calculator which measures BMI (Body Mass Index). I have already post a tutorial to make a BMI calculator in Javascript .

BMI :  According to Wikipedia The BMI is an attempt to quantify the amount of tissue mass (muscle, fat, and bone) in an individual, and then categorize that person as underweight, normal weight, overweight, or obese based on that value.

Formula : BMI = W / (H/100 * H/100)

Where W is weight in KG and H stands for Height in Centimeter.

BMI Categories:
Underweight  <18.5
Normal weight = 18.5–24.9
Overweight = 25–29.9
Obesity = BMI of 30 or greater

## Script For BMI Calculator in Java Create a file BmiCalculator.java
``` import java.util.Scanner; public class BmiCalculator{ /* * By Sanjay Prasad * BMI(Body Mass Index) calculator * Body mass index (BMI) is a measure of body fat based on height and weight * that applies to adult men and women. */ public static void main(String[] args){ double cm,kg,bmi,newcm; Scanner in=new Scanner(System.in); System.out.println("Enter your height in CM"); cm=in.nextDouble(); System.out.println("Enter your Weight in KG"); kg=in.nextDouble(); newcm= cm/100; bmi=kg/(newcm*newcm); System.out.println("Your BMI : " + bmi ); bmi=Math.round(bmi); System.out.println("Rounded BMI : " + bmi ); System.out.println("BMI Analysis"); if(bmi<18.5){ System.out.println("Thin"); }else if(bmi>18.5 && bmi <=24.9){ System.out.println("Normal"); }else{ System.out.println("Fat"); } } } ```

Compile in command prompt / terminal : javac BmiCalculator.java
Execute code : java BmiCalculator 