Kuroneko - chan
Addict
- Joined
- Apr 29, 2016
- Posts
- 100
- Reaction
- 12
- Points
- 84
- Age
- 23
Code:
import java.util.Scanner;
public class BMI
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
int formula;
System.out.println("Choose a formula: 1 for Metric Unit and 2 for Imperial Unit");
formula = input.nextInt();
switch(formula){
case 1:
double BMI, kg, m;
System.out.print("Enter your weight in Kilo: ");
kg = input.nextDouble();
System.out.print("Enter your height in Meter: ");
m = input.nextDouble();
BMI = kg / (m * m);
System.out.println("your Body Mass Index is: " + BMI + " kg/m");
if(BMI < 18.5){
System.out.println("You are Underweight");
}
else if(BMI > 18.5 - 24.9){
System.out.println("You are Normal and Healty");
}
else if(BMI >= 25 - 29.9){
System.out.println("You are Overweight");
}
else if(BMI >= 30){
System.out.println("You are Obese");
}
else{
System.out.println("You are not a Human");
}
break;
case 2:
double bmi, lbs, inc;
System.out.print("Enter your weight in lbs: ");
lbs = input.nextDouble();
System.out.print("Enter your height in inches: ");
inc = input.nextDouble();
final int z = 703;
bmi = (z * lbs) / (inc * inc);
System.out.println("Your Body Mass Index is: " + bmi + " lbs/inc");
if(bmi < 18.5){
System.out.println("You are Underweight");
}
else if(bmi >= 18.5 - 24.9){
System.out.println("You are Normal and Healty");
}
else if(bmi >= 25 - 29.9){
System.out.println("You are Overweight");
}
else if(bmi >= 30){
System.out.println("You are Obese");
}
else{
System.out.println("You are not a Human");
}
break;
default:
System.out.println("You input a wrong value");
break;
}
}
}