- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Java program to calculate Body Mass Index (BMI)

The Body Mass Index is the body mass in kilogram divided by the square of body height in meters. This is expressed as kg/m^2.

A program that calculates the Body Mass Index (BMI) is given as follows.

## Example

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("

Input height in meters: "); double height = sc.nextDouble(); double BMI = weight / (height * height); System.out.print("

The Body Mass Index (BMI) is " + BMI + " kg/m2"); } }

## Output

Input weight in kilogram: 55 Input height in meters: 1.5 The Body Mass Index (BMI) is 24.444444444444443 kg/m2

Now let us understand the above program.

The values of the weight and height are obtained from the user in kilogram and meters respectively. The code snippet that demonstrates this is given as follows −

Scanner sc = new Scanner(System.in); System.out.print("Input weight in kilogram: "); double weight = sc.nextDouble(); System.out.print("

Input height in meters: "); double height = sc.nextDouble();

Then the Body Mass Index is calculated using the formula BMI = weight / (height * height). Finally the values of the Body Mass Index is displayed. The code snippet that demonstrates this is given as follows −

double BMI = weight / (height * height); System.out.print("

The Body Mass Index (BMI) is " + BMI + " kg/m2");

- Related Questions & Answers
- C program to Calculate Body Mass Index (BMI)
- Python program to calculate BMI(Body Mass Index) of your Body
- Java program to calculate mode in Java
- Java program to calculate student grades
- Java program to calculate the percentage
- Java Program to calculate Compound Interest
- Java Program to Calculate Standard Deviation
- Java Program to Calculate Simple Interest
- Mass Storage Management
- Java Program to calculate distance light travels
- Java Program to Calculate the Compound Interest
- Mass insertion in MongoDB
- Java program to calculate mean of given numbers
- Java Program to calculate area of a Tetrahedron
- Java Program to Calculate union of two sets

Advertisements