What I want to do :
I made a BMI calculator (Formula=(KG*KG)/M) The input takes eg 186 but i get an error when inserting 1.86 (For height in metres)
java.lang.NumberFormatException: For input string: "1.86"
Here is my code :
if (txtHeight.getText().length() > 0 && txtWeight.getText().length() > 0){
height = Integer.parseInt(txtHeight.getText());
heightsqr = (int) Math.pow(height, 2);
mass = Integer.parseInt(txtWeight.getText());
bmi = (heightsqr/ mass);
lblBmi.setText("Current BMI : " + Integer.toString(bmi));
}
else{
JOptionPane.showMessageDialog(this, "Please enter your weight in KG and your Height in M");
}
It's a pretty basic error that I just cant seem to fix