Skip to content

Commit fc25513

Browse files
BMI
1 parent b300bac commit fc25513

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

BMI.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import java.util.Scanner;
2+
public class BMI{
3+
public static void main(String[] args) {
4+
Scanner scanner = new Scanner(System.in);
5+
6+
System.out.print("Enter your weight in kilograms: ");
7+
double weight = scanner.nextDouble();
8+
9+
System.out.print("Enter your height in meters: ");
10+
double height = scanner.nextDouble();
11+
12+
double bmi = weight / (height * height);
13+
System.out.printf("Your BMI is: %.2f%n", bmi);
14+
15+
if (bmi < 18.5) {
16+
System.out.println("You are underweight.");
17+
} else if (bmi >= 18.5 && bmi < 24.9) {
18+
System.out.println("You have a normal weight.");
19+
} else if (bmi >= 25 && bmi < 29.9) {
20+
System.out.println("You are overweight.");
21+
} else {
22+
System.out.println("You are obese.");
23+
}
24+
25+
scanner.close();
26+
}
27+
}

0 commit comments

Comments
 (0)