0

i m making a BMI calculator GUI which calcuates weight in corresponding to height shown on slider but there is some error in program. problem lies in following line

int value = slider.getValue();
        int weight=0;
	if (if buttonGroup.getSelected()=="Male")
	{
	weight=value/28;
	}
	else if (buttonGroup.getSelected()==Female)
	{
	weight=value/30;
	}
          System.out.println("weight");
3
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by javaNooblet
0

The compiler error message tells you exactly what the error is and exactly which line it's on. "some error in program" is useless as a problem description.

1

In line 3 you have if(if "condition". Don't think there should be two ifs there.

You should not be testing a button group either. It is just something that can group radio buttons, checkboxes, etc... together. Test the individual checkbox/radiobutton(whatever you have) instead of the button group.

Try something like:

if(maleCheckbox.isSelected())

(this is assuming you are using checkboxes for your options)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.