-
Notifications
You must be signed in to change notification settings - Fork 0
/
BodyMassIndexCalculator.java
36 lines (26 loc) · 1.19 KB
/
BodyMassIndexCalculator.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
// Create a Body Mass Index Calculator
// Prompt the user for
import java.util.Scanner;
public class BodyMassIndexCalculator
{
public static void main ( String[] arg )
{
Scanner input = new Scanner( System.in );
float weight; // store user weight
float heightCm; // store user hight
System.out.println( "Enter your weight in kg: " ); // prompt
weight = input.nextInt(); // store input
System.out.println( "Enter your hight in cm: " ); // prompt
heightCm = input.nextInt(); // store input
System.out.println( "" ); // add line to separate
// print the BMI. multiplied BMI by 10000 to more comma right
System.out.printf( "Your BMI is: %f\n", ( weight / ( heightCm * heightCm ) ) * 10000 );
System.out.println( "" ); // add line to separate
// Information from the Department of Health and Human Services/National Instituition of Health
System.out.printf( "%s\n", "BMI VALUES" );
System.out.printf( "Underweight: %s", "\t less than 18.5\n" );
System.out.printf( "Normal: %s", "\t between 18.5 and 24.9\n" );
System.out.printf( "Overweight: %s", "\t between 25 and 29.9\n" );
System.out.printf( "Obese: %s", "\t\t 30 or greater\n" );
}
}