Kuroneko - chan
Journeyman
Code:
import java.util.*;
public class BmiClasses
{
public static void main(String[] args)
{
BmiClasses a = new BmiClasses();
a.option();
}
public void option(){
Compute a = new Compute();
Scanner in = new Scanner(System.in);
double c, d;
System.out.println("Enter choice: \n1:Metric Unit \n2:Imperial Unit");
int x = in.nextInt();
if(x == 1){
System.out.println("Enter weight in kilo: ");
c = in.nextDouble();
System.out.println("Enter height in meter: ");
d = in.nextDouble();
a.metric(c,d);
a.identify();
option();
}
else if(x == 2){
System.out.println("Enter weight in pounds: ");
c = in.nextDouble();
System.out.println("Enter height in inches: ");
d = in.nextDouble();
a.imperial(c,d);
a.identify();
option();
}
else{
System.out.println("Invalid choice: " + x);
option();
}
}
}
class Compute{
double bmi;
public void metric(double c, double d){
bmi = c / (d * d);
System.out.println("Your Body Mass Index: " + bmi);
}
public void imperial(double c, double d){
final int z = 703;
bmi = (z * c) / (d * d);
System.out.println("Your Body Mass Index: " + bmi);
}
public void identify(){
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");
}
}
}
Or download here:
You do not have permission to view the full content of this post. Log in or register now.
