Bmi calculator with java by Indranil Bhattacharjee.
Bmi calculator in java with Brithish rule & Metrix rule in java.
and say overweight,Obese,under weight etc.
import java.util.Scanner;
class BMICal {
public static void main(String[] args) {
float bmi, kg, m, lb, inch;
char choice, ch;
Scanner sc = new Scanner(System.in);
System.out.print("weight in kg Y/N ?");
choice = sc.next().charAt(0);
switch (choice) {
case 'Y':
System.out.print("Enter weight in kg:-");
kg = sc.nextFloat();
System.out.print("Enter height in inch y/n:-");
ch = sc.next().charAt(0);
switch (ch) {
case 'Y':
System.out.print("Enter height in inch:-");
inch = sc.nextFloat();
m = inch * 100 / 3048;
bmi = kg / (m * m);
System.out.print("Bmi is:- " + bmi);
break;
case 'N':
System.out.print("Enter height in meter:-");
m = sc.nextFloat();
bmi = kg / (m * m);
System.out.print("Bmi is:- " + bmi);
sc.close();
}
break;
case 'N':
System.out.print("Enter weight in lb:-");
lb = sc.nextFloat();
kg = lb * 10000 / 4536;
System.out.print("Enter height in inch:-");
inch = sc.nextFloat();
m = inch * 100 / 3048;
bmi = kg / (m * m);
System.out.print("Bmi is:- " + bmi);
sc.close();
break;
}
if (bmi >= 18.5 && bmi <= 24) {
System.out.println("\nNormal weight");
}
else if(bmi>=25 && bmi<=29.9){
System.out.println("\nOver weight");
}
else if(bmi<18.5){
System.out.println("\nUnder Weight");
}
else
{
System.out.println("\nObese");
}
}
}
Comments
Post a Comment