Why my if-else statement doesn't execute when gender == "m"
or gender == "f"
?
Scanner input = new Scanner(System.in);
do
{
System.out.print("Please enter 'm' for male and 'f' for female child: ");
String gender = input.next();
System.out.print("The height of the mother in inches: ");
int motherHeight = input.nextInt();
System.out.println("The height of the father in inches: ");
int fatherHeight = input.nextInt();
if(gender == "m")
{
double childHeight = ((motherHeight * 13/12) + fatherHeight) / 2;
System.out.println(childHeight);
}
else if (gender == "f")
{
double childHeight = ((fatherHeight * 13/14) + motherHeight) / 2;
System.out.println(childHeight);
}
}
while(input.hasNext());