-
Notifications
You must be signed in to change notification settings - Fork 0
/
BMICalculator.java
55 lines (44 loc) · 3.29 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import java.util.Scanner;
public class BMICalculator {
public static double calculateBMI(double weight, double height) {
return weight / (height * height);
}
public static void interpretBMI(double bmi) {
System.out.print("BMI Interpretation: ");
if (bmi < 18.5) {
System.out.println("Underweight");
} else if (bmi >= 18.5 && bmi < 25) {
System.out.println("Normal weight");
} else if (bmi >= 25 && bmi < 30) {
System.out.println("Overweight");
} else {
System.out.println("Obesity");
}
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("\t██████╗ ███╗ ███╗██╗ ");
System.out.println("\t██╔══██╗████╗ ████║██║ ");
System.out.println("\t██████╔╝██╔████╔██║██║ ");
System.out.println("\t██╔══██╗██║╚██╔╝██║██║ ");
System.out.println("\t██████╔╝██║ ╚═╝ ██║██║ ");
System.out.println("\t╚═════╝ ╚═╝ ╚═╝╚═╝ ");
System.out.println(" ██████╗ █████╗ ██╗ ██████╗██╗ ██╗██╗ █████╗ ████████╗ ██████╗ ██████╗ ");
System.out.println(" ██╔════╝██╔══██╗██║ ██╔════╝██║ ██║██║ ██╔══██╗╚══██╔══╝██╔═══██╗██╔══██╗ ");
System.out.println(" ██║ ███████║██║ ██║ ██║ ██║██║ ███████║ ██║ ██║ ██║██████╔╝ ");
System.out.println(" ██║ ██╔══██║██║ ██║ ██║ ██║██║ ██╔══██║ ██║ ██║ ██║██╔══██╗ ");
System.out.println(" ╚██████╗██║ ██║███████╗╚██████╗╚██████╔╝███████╗██║ ██║ ██║ ╚██████╔╝██║ ██║ ");
System.out.println(" ╚═════╝╚═╝ ╚═╝╚══════╝ ╚═════╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ");
System.out.print("\nEnter weight in kilograms: ");
double weight = scanner.nextDouble();
System.out.print("\nEnter height in meters: ");
double height = scanner.nextDouble();
double bmi = calculateBMI(weight, height);
System.out.println("_______________________________");
System.out.println("\n Your BMI is: " + bmi);
System.out.println("_______________________________\n");
interpretBMI(bmi);
System.out.println("\n_______________________________\n");
scanner.close();
}
}