-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBMI.java
More file actions
37 lines (27 loc) · 909 Bytes
/
BMI.java
File metadata and controls
37 lines (27 loc) · 909 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
28
29
30
31
32
33
34
35
36
37
public class BMI extends GaddisChallenges {
private double userWeight; //pounds
private double userHeight; //inches
private double userBmi;
private String weightStatus;
public void start() {
collectInfo();
userBmi = userWeight * 703/(userHeight * userHeight);
if (userBmi >= 18.5 && userBmi < 25) {
weightStatus = "optimal";
}
else if (userBmi < 18.5) {
weightStatus = "underweight";
}
else if (userBmi > 25) {
weightStatus = "overweight";
}
print("Based on your height and weight, your BMI is "
+ userBmi + " so your weight is " + weightStatus);
}
private void collectInfo() {
print("What is your height? ");
userHeight = scan.nextDouble();
print("What is your weight? ");
userWeight = scan.nextDouble();
}
}