# Java Health Application: Computing BMI

The program below is the answer to Liang's Introduction to Java Programming (9th Edition) Chapter  2 Exercise 2.14.

Question: Health application: computing BMI) Body Mass Index (BMI) is a measure of health on weight. It can be calculated by taking your weight in kilograms and dividing by the square of your height in meters. Write a program that prompts the user to enter a weight in pounds and height in inches and displays the BMI. Note that one pound is 0.45359237 kilograms and one inch is 0.0254 meters.

```/**
*
* @Author: Aghatise Osazuwa
* Website: www.cscprogrammingtutorials.com
*
* Exercise 2.14 - Health Application: Computing BMI
*
*/

import java.util.Scanner;

public class ComputingBMI {

public static void main(String[] args) {

//Display Program Information
System.out.println("This Program Calculates Body Mass Index (BMI).\n");

//create Scanner
Scanner input = new Scanner(System.in);

//prompt user to enter details
System.out.println("Enter weight in pounds:");
double weight = input.nextDouble();
System.out.println("Enter height in inches:");
double height = input.nextDouble();

//calculate the BMI
weight = weight * 0.45359237; //convert weight to kilograms
height = height * 0.0254; //convert height to meters

double bMI = weight / (height * height);
//format BMI to four decimal places
bMI = (int) (bMI * 10000) / 10000.0;

//display the result
System.out.println("BMI is " + bMI + "\n");
}
}
```