public class TestingIf-Else //My class for determining child height
{
public static void main(String[] args)
{
//Setting my variables.
DecimalFormat neat = new DecimalFormat("#.00"); // Setting neat to two decimals
Scanner keyboard = new Scanner(System.in); // Initalizing keyboard to scanner input
int feetD, inchesD;
int feetM, inchesM;
double Hmale_child, Hfemale_child;
String gender;
//Prompt for gender
System.out.println("Enter gender here. Either M for male, or F for female");
gender = keyboard.next();
if (gender.equalsIgnoreCase("m"))
{gender = "Male";}
else if (gender.equalsIgnoreCase("f"))
{gender = "Female";}
else
{gender = "Incorrect input, try again.";
System.exit(0);}
System.out.println("This is the input for gender: " + gender);
// Inputs for fathers height, feet and inches.
System.out.println("Fathers height in feet: ");
feetD = keyboard.nextInt();
System.out.println("Fathers height in inches: ");
inchesD = keyboard.nextInt();
// Inputs for mothers height, feet and inches.
System.out.println("Mothers height in feet: ");
feetM = keyboard.nextInt();
System.out.println("Mothers height in inches: ");
inchesM = keyboard.nextInt();
//Converting both heights to inches.
double totInchesD = ((feetD * 12) + inchesD);
double totInchesM = ((feetM * 12) + inchesM);
//Determining estimated child height.
if (gender.equals("Male"))
{
Hmale_child=((totInchesM * (13/12) + totInchesD)/2);
System.out.println(neat.format(Hmale_child));
}
else
{
Hfemale_child=((totInchesD * (13/12) + totInchesM)/2);
System.out.println(neat.format(Hfemale_child));
System.out.println("Check");
}
}
}
I've sat here for two days trying to logically go through, i need another set of eyes please! I don't understand it, no matter the case, all values for both Hmale, and Hfemale child all come out to the same.