title: Calculate BMI in Java using metrics
body: <p>Please bear with me, I'm an interactive design student in week 2 of a Java class. </p>
  
  <p>I need to create a BMI calculator using the following formula:Calculate the BMI using the following formula:</p>
  
  <pre><code>           w
   BMI =    ___
         (h/100) 2
  </code></pre>
  
  <p>where w is weight in kilograms and h is height in centimeters. Note that the denominator is squared.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>    /**
   * Calculates the Body Mass Index (BMI) for the user. The user must type in his
   * or her height in centimeters and weight in kilograms, and the computer prints
   * out the user's BMI.
   */
  import java.util.Scanner; // import class
  public class BMI {
      public static void main(String[] args) {
          int weight;
          int height;
          double bmi;
          Scanner console; //  create a variable to represent the console
          console = new Scanner (System.in); //  create the object with new
          System.out.print("How much do you weigh (in kg)? "); // user prompt to provide weight
          weight = console.nextInt(); // read from console
          System.out.print("How tall are you (in cm)? "); // user prompt to provide height
          height = console.nextInt(); // read value from console
          bmi = (double) weight / (height/100*height/100); // calculates BMI
          System.out.println("Your BMI is " + bmi); // displays user's BMI
      }
  }
  </code></pre>
  
  <p>The program if one can call it that, runs but I think the calculation written incorrectly. </p>
  
  <p>I've formatted the calculation several ways:
  bmi = (double) weight / (height/100*height/100); returns the weight EXCEPT when I use 100 for the weight and 200 for the height.  I've tried the following:</p>
  
  <p>bmi = (double)weight / height/100*height/100; </p>
  
  <p>bmi = (double) weight / (height/100*height/100); </p>
  
  <p>bmi = (double) weight / (height/100)*(height/100); </p>
  
  <p>bmi = (double) weight / ((height/100)*(height/100)); </p>
  
  <p>bmi = (double)(weight / height/100*height/100); </p>
  
  <p>bmi = (double) (weight / (height/100*height/100); </p>
  
  <p>bmi = (double) (weight /(height/100)*(height/100); </p>
  
  <p>bmi = (double)(weight) / ((height/100)*(height/100));  </p>
  
  <p>bmi = (double)(weight) / ((height/100)*(height/100)); </p>
  
  <p>bmi = (double)(weight) / height/100*height/100;</p>
  
  <p>I either get the weight 100% of the time or it only works with 100 and 200 as the variables.  I tried 75 and 150 and that also returns the weight.  </p>
  
  <p>At this point I don't even remember PEMDAS</p>