-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbmicalculator.java
32 lines (29 loc) · 1.01 KB
/
bmicalculator.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import java.util.Scanner;
public class bmicalculator {
public static void main(String[] args) {
double height,weight,bmi;
Scanner ne = new Scanner(System.in);
System.out.println("Enter your height in inches");
//getting the height
height=ne.nextDouble();
height=height*0.3048;
//getting the weight
System.out.println("Enter your weight in kilos");
weight=ne.nextDouble();
//calculating the BMI
bmi=weight/height;
bmi=bmi/height;
if (bmi<18.5){
System.out.println("Your BMI is "+" "+bmi+" "+"You are underweight");
}
else if (bmi<=24.9 || bmi>= 18.5){
System.out.println("Your BMI is "+" "+bmi+" "+"You are normal weight");
}
else if (bmi<=29.9 || bmi>= 25){
System.out.println("Your BMI is "+" "+bmi+" "+"You are overweight");
}
else if (bmi<=30){
System.out.println("Your BMI is "+" "+bmi+" "+"You are Obese");
}
}
}