Q-36- The body mass index (BMI) is commonly used by health and nutrition professionals to estimate human body fat in populations. It is computed by taking the individual's weight (mass) in kilograms and dividing it by the square of their height in meters. i.e.
𝑀𝑒𝑡𝑟𝑖𝑐:𝐵𝑀𝐼 =𝑊𝑒𝑖𝑔ℎ𝑡 (𝑘𝑔) /(𝐻𝑒𝑖𝑔ℎ𝑡(𝑚))2
Write a java program by using some if statements to show the category for a given BMI.
BMI Category
less than 18.5 underweight 18.5 to 24.9 normal weight 25.0 to 29.9 overweight 30.0 or more obese
INPUT :
import java.util.Scanner;
public class NCM {
public static void main(String[] args) {
@SuppressWarnings("resource")
Scanner sc=new Scanner(System.in);
double weight ,height;
System.out.println("Enter The Weight In Kilogram :");
weight=sc.nextDouble();
System.out.println("Enter The Height In Meter :");
height=sc.nextDouble();
double bmi=weight/(height*height);
System.out.println("BMI Is :"+bmi);
if(bmi<18.5)
{
System.out.println("You Are In Underweight.");
}
else if(bmi>=18.5 && bmi<=24.9)
{
System.out.println("You Are In Normal Weight.");
}
else if(bmi>=25 && bmi<=29.9)
{
System.out.println("You Are In Overweight.");
}
else if(bmi>=30)
{
System.out.println("You Are In Obese.");
}
}
}
OUTPUT :
Enter The Weight In Kilogram :
80
Enter The Height In Meter :
1.6
BMI Is :31.249999999999993
You Are In Obese.
𝑀𝑒𝑡𝑟𝑖𝑐:𝐵𝑀𝐼 =𝑊𝑒𝑖𝑔ℎ𝑡 (𝑘𝑔) /(𝐻𝑒𝑖𝑔ℎ𝑡(𝑚))2
Write a java program by using some if statements to show the category for a given BMI.
BMI Category
less than 18.5 underweight 18.5 to 24.9 normal weight 25.0 to 29.9 overweight 30.0 or more obese
INPUT :
import java.util.Scanner;
public class NCM {
public static void main(String[] args) {
@SuppressWarnings("resource")
Scanner sc=new Scanner(System.in);
double weight ,height;
System.out.println("Enter The Weight In Kilogram :");
weight=sc.nextDouble();
System.out.println("Enter The Height In Meter :");
height=sc.nextDouble();
double bmi=weight/(height*height);
System.out.println("BMI Is :"+bmi);
if(bmi<18.5)
{
System.out.println("You Are In Underweight.");
}
else if(bmi>=18.5 && bmi<=24.9)
{
System.out.println("You Are In Normal Weight.");
}
else if(bmi>=25 && bmi<=29.9)
{
System.out.println("You Are In Overweight.");
}
else if(bmi>=30)
{
System.out.println("You Are In Obese.");
}
}
}
Enter The Weight In Kilogram :
80
Enter The Height In Meter :
1.6
BMI Is :31.249999999999993
You Are In Obese.
No comments:
Post a Comment