Java progarm for check your ideal weight according your height

Hello Guys,
I am presenting a new java program with maths logic to check your weight according your height :-

public class CheckYouWeight {

 public static void main(String[] args) {
 
  System.out.println("Enter your gender\r\n press 1 for male \r\n press 2 for female");
  Scanner sc = new Scanner(System.in);
  int gender = sc.nextInt();
 
  System.out.println("Enter your height feet and inches for ex:- 5 feet 10 inches");
 
  Scanner sc2 = new Scanner(System.in);
  String height = sc2.nextLine();
  String heightArr[] = height.split(" ");
  int feet = Integer.parseInt(heightArr[0]);
  int inches = Integer.parseInt(heightArr[2]);
 
  int totalInches = feet*12+inches;
  int effectiveInches = totalInches-60;
 
  if(feet <5 || feet >=8){
   System.out.println("Please enter height in between 5 to 8 feet");
  }else if(inches <0 || inches >11){
   System.out.println("Please enter height in between 0 to 11 inches");
  }else{
 
   if(gender == 1){
    float weight = 50+((float)2.3*effectiveInches);
    System.out.println("your ideal weight should be:- "+weight+" Kg");
   }else{
    float weight = (float)45.5+((float)2.3*effectiveInches);
    System.out.println("your ideal weight should be:- "+weight+" Kg");
   }
  }
 }
}

Comments