Java Program To Check Body Mass Index

Java Program To Check Body Mass Index
import java.util.Scanner;
class BMI
{
   public static void main(String args[])
   {
Scanner sc = new Scanner(System.in);
float weight;
float height;
float bmi;
System.out.print("Enter weight in kg : ");
weight = sc.nextFloat();
System.out.print("Enter height in m : ");
height = sc.nextFloat();
bmi = (weight)/(height*height);
System.out.println("Body Mass Index (BMI) : " + bmi);
if(bmi<=15 )
   System.out.println("You are very severly underweight.");
else if(bmi<=16)
System.out.println("You are severly underweight.");
else if(bmi<=18.5)
   System.out.println("You are underweight.");
else if(bmi<=25)
   System.out.println("Your Weight is Normal.");
else if(bmi<=30)
   System.out.println("You are over underweight.");
else if(bmi<=35)
   System.out.println("You are moderately obese.");
else if(bmi<=40)
   System.out.println("You are severly obese.");
else
   System.out.println("Invalid BMI");
    }

}
OUTPUT:
Enter weight in kg : 50
Enter height in m : 1.5
Body Mass Index (BMI) : 22.222221
Your Weight is Normal .

tags : java , java programs , c , programs of c , c++ , programs of c++ , tutorialspoint , tutorialspoint java , code camp

Post a Comment

Previous Post Next Post