GTU OOP Program - 4
4). 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:- 1 pound=.45359237
Kg and 1 inch=.0254 meters.
import java.util.Scanner; class Program_04 { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter your weight in Pound : "); double weight = input.nextDouble(); System.out.print("Enter your height in inches : "); double height = input.nextDouble(); double BMI = (weight * 0.45359237) / ((height * 0.0254) * (height * 0.0254)); System.out.print("BMI = " + BMI); } }
Output
Comments