-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBMI.java
More file actions
27 lines (22 loc) · 863 Bytes
/
BMI.java
File metadata and controls
27 lines (22 loc) · 863 Bytes
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
import java.util.Scanner;
public class BMI{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter your weight in kilograms: ");
double weight = scanner.nextDouble();
System.out.print("Enter your height in meters: ");
double height = scanner.nextDouble();
double bmi = weight / (height * height);
System.out.printf("Your BMI is: %.2f%n", bmi);
if (bmi < 18.5) {
System.out.println("You are underweight.");
} else if (bmi >= 18.5 && bmi < 24.9) {
System.out.println("You have a normal weight.");
} else if (bmi >= 25 && bmi < 29.9) {
System.out.println("You are overweight.");
} else {
System.out.println("You are obese.");
}
scanner.close();
}
}