-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBodyMassIndex.java
More file actions
30 lines (30 loc) · 1.21 KB
/
BodyMassIndex.java
File metadata and controls
30 lines (30 loc) · 1.21 KB
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
/**
* QUESTION THREE
* @author WACHIRA BENARD KIMANI
*/
import java.util.Scanner;
public class BodyMassIndex {
public static void main(String args[]) {
Scanner keypad = new Scanner(System.in);
double weight, height;//DECLARE NULL VARIABLES
while(true){
try{
System.out.print("\n Enter Weight: ");
weight = keypad.nextDouble();//REQUEST WEIGHT
System.out.print("\n Enter Height: ");
height = keypad.nextDouble();//REQUEST HEIGHT
System.out.print("\n Your BMI is: " +
(weight / (height * height)) + "\n");//GET BMI VVALUE
}catch(Exception e){
break;
}
System.out.print("\n BMI VALUES \n");
//PRINT BMI VALUES IN A FORMATTED FASHION FOR CLARITY
System.out.print("\n UNDER WEIGHT" + "\t\t\t" + "LESS THAN 18.5");
System.out.print("\n NORMAL" + "\t\t\t" + "BETWEEN 18.5 AND 24.9");
System.out.print("\n OVERWEIGHT" + "\t\t\t" + "BETWEEN 25 AND 29.9");
System.out.print("\n OBESE" + "\t\t\t" + "30 OR GREATER");
System.out.print("\n\n");
}
}
}