I'm pretty new to programming and am currently teaching myself Java. I'm trying to make a program that involves BMI, but I keep on having 0
displayed instead of a BMI value.
I'm pretty sure my error is in the math, but I don't know what to change:
public class bmi {
public static void main(String[] args) {
Scanner k = new Scanner(System.in);
System.out.print("Weight(kg):");
int weight=k.nextInt();
//now for the second scanner or int
Scanner j = new Scanner(System.in);
System.out.print("Height (m):");
int height=j.nextInt();
double bodyMassIndex = ((double) weight / (height * height));
//so far this looks fine i believe , however there might be a problem with the math.
System.out.println(bodyMassIndex);
}
}