Like Us Like Us Facebook Subscribe Subscribe us YouTube Whatsapp Share us Whatsapp Query Send your queries

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

BMI Calculator in JAVA

Create a file

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.out.println("Enter your height in CM");
System.out.println("Enter your Weight in KG");
newcm= cm/100;
System.out.println("Your BMI : " + 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){

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

0 0 votes
Article Rating
Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Inline Feedbacks
View all comments