Write a program that computes the body mass index (BMI) of an individual. Your program should begin by reading a height and weight from the user. If you read the height in meters and the weight in kilograms then body mass index is computed using this slightly simpler formula:
BMI = weight / height*height
Height = Float
Weight =integer
Input:
height = 1.69
weight = 64
Output:
BMI = 22.41
import java.io.*; import java.util.*; public class temp{ public static void main(String[] args){ Scanner s=new Scanner(System.in); System.out.print("Enter the Height: "); float H = s.nextFloat(); System.out.print("Enter the Weight: "); int W = s.nextInt(); double BMI = W / (H*H); System.out.println("The BMI is "+String.format("%.2f",BMI)); } }
INPUT_1:
Enter the Height: 1.69
Enter the Weight: 64
OUTPUT:
The BMI is 22.41
INPUT_2:
Enter the Height: 1.72
Enter the Weight: 71
OUTPUT:
The BMI is 24.00
INPUT_3:
Enter the Height: 1.56
Enter the Weight: 50
OUTPUT:
The BMI is 20.55
INPUT_4:
Enter the Height: 2
Enter the Weight: 60
OUTPUT:
The BMI is 15.00
INPUT_5:
Enter the Height: 1.66
Enter the Weight: 45
OUTPUT:
The BMI is 16.33
ILLUSTRATION
![](http://www.fcukthecode.com/wp-content/uploads/2022/04/Screenshot-2022-04-23-204935.png)