I have to create a Java-based application (using the BlueJ interface and compiler) that caluclates body mass index. I have a code developed, but for some reason I keep getting an error saying that "non-static method cannot be referenced from a static context". Could somebody please help me fix this?:
public class Java016A {
public int index (int weight, int height) {
int bmi = 10000 * (weight / (height^2));
return bmi;
}
public static void main () {
int weight, height, bmass;
weight = 50;
height = 120;
bmass = index(weight, height);
System.out.println("Body Mass Index: " + bmass);
}
}
2006-10-19
18:35:07
·
2 answers
·
asked by
NiceShyGuy
1
in
Programming & Design