- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHealthApp.java
More file actions
Latest commit
40 lines (28 loc) · 1.15 KB
/
Copy pathHealthApp.java
File metadata and controls
40 lines (28 loc) · 1.15 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
31
32
33
34
35
36
37
38
39
40
/* Christopher Yonek
CSC:164-651 - Mr. Ng.
Programming Exercise 2: Health Application
1/23/2020
*/
importjava.util.Scanner;
importjava.math.BigDecimal;
importjava.math.RoundingMode;
publicclassHealthApp{
publicstaticvoidmain(Stringargs[]) {
finaldoubleoneLb = 0.45359237;
finaldoubleoneM = 0.0254;
//Create scanner
ScanneruserInput = newScanner(System.in);
//Ask for weight to convert
System.out.println("Enter your weight in Pounds (Lb)");
doubleweight = userInput.nextDouble();
doubleweightKg = oneLb * weight;
//Ask user to enter height in inches
System.out.println("Enter your height in Inches (in)");
doubleheight =userInput.nextDouble();
doubleheightMeters = oneM * height;
//Calculate BMI and keep to 4 decimal values
doubleuserBMI = weightKg / (heightMeters * heightMeters);
doubleprecisionSetBMI = BigDecimal.valueOf(userBMI).setScale(4,RoundingMode.HALF_UP).doubleValue();
System.out.println("Your BMI is: " + precisionSetBMI);
}
}