title: Java program crashes, when giving a decimal point, but works with int
body: <p>When a user enters a whole number, the program runs smoothly, but when the user enters a number that has a decimal at the end, the program crashes.  </p>
  
  <p>These are the errors that I get:</p>
  
  <pre><code>    at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
      at java.lang.Integer.parseInt(Integer.java:458)
      at java.lang.Integer.parseInt(Integer.java:499)
      at BMI.main(BMI.java:11)
  </code></pre>
  
  <p>Here is my code:</p>
  
  <pre><code>import javax.swing.*;
  
  public class BMI {
    public static void main(String args[]) {
      int height;  // declares the height variable
      int weight;  // declares the weight variable
      String getweight;
      getweight = JOptionPane.showInputDialog(null, "Please enter your weight in Kilograms");  // asks user for their weight
      String getheight;
      getheight = JOptionPane.showInputDialog(null, "Please enter your height in Centimeters");  // asks user for their height
      weight = Integer.parseInt(getweight);  // stores their weight
      height = Integer.parseInt(getheight);  // stores their height
      double bmi;  // declares the BMI variable
      bmi = weight / Math.pow(height / 100.0, 2.0);  // calculates the BMI
      double roundbmi;  // variable to round the BMI to make it more read-able
      roundbmi = Math.round(bmi);  // rounds the BMI
      JOptionPane.showMessageDialog(null, "Your BMI is: " + roundbmi);  // displays the calculated and rounded BMI
    }
  }
  </code></pre>