I'm trying to make a program that will give you your "ideal" weight, and think I have it mostly figured out. However, when I run the code nothing happens. I think this is because it's not properly retrieving the indicator if it should be metric or imperial.
String name, heightString, unitString; double height;
name = nameInput.getText();
unitString = unitInput.getText();
heightString = heightInput.getText();
height = Double.parseDouble(heightString);
if (unitString == "m")
{
outputLabel.setText(name + "'s ideal weight is" + (height * height * 25) + "kgs");
}
else if (unitString == "i")
{
outputLabel.setText(name + "'s ideal weight is" + (height * height * 25 / 703 + "lbs"));
}
That's what I have, I'm fairly sure the issue is I didn't have the condition for the if statement correct, but I'm not able to find what I should be doing.