Q-19- 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 java 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.
INPUT :
import java.util.Scanner;
public class NCM {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc=new Scanner(System.in);
double pound,inch;
System.out.println("Enter The Weight In Pounds:");
pound=sc.nextDouble();
System.out.println("Enter The Height In Inches:");
inch=sc.nextDouble();
double weight=pound*0.45359237;
double height=inch*0.0254;
double bmi=weight/(height*height);
System.out.println("BMI is "+bmi);
}
}
OUTPUT :
Enter The Weight In Pounds:
95.5
Enter The Height In Inches:
50
BMI is 26.857257942215885
INPUT :
import java.util.Scanner;
public class NCM {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc=new Scanner(System.in);
double pound,inch;
System.out.println("Enter The Weight In Pounds:");
pound=sc.nextDouble();
System.out.println("Enter The Height In Inches:");
inch=sc.nextDouble();
double weight=pound*0.45359237;
double height=inch*0.0254;
double bmi=weight/(height*height);
System.out.println("BMI is "+bmi);
}
}
Enter The Weight In Pounds:
95.5
Enter The Height In Inches:
50
BMI is 26.857257942215885
No comments:
Post a Comment