title: Exception in thread "main" java.util.InputMismatchException. Scanner-class
body: <p>I've looked through some of the questions but I can't seem to find any good solutions.</p>
  
  <p>I have a very simple code that just won't work. It's supposed to get the weight and height of the user, and then compute the BMI.</p>
  
  <p>The values I put in is different everytime.
  But lets say 85 for variable vikt and 1.80 for variable langd.
  It does work when i use a , instead of a . though.
  I get the following error.</p>
  
  <pre><code>Exception in thread "main" java.util.InputMismatchException
      at java.util.Scanner.throwFor(Scanner.java:864)
      at java.util.Scanner.next(Scanner.java:1485)
      at java.util.Scanner.nextDouble(Scanner.java:2413)
      at Labb2.BMI.main(BMI.java:32)
  C:\Users\Danne\AppData\Local\NetBeans\Cache\8.2\executor-snippets\run.xml:53: Java returned: 1
  BUILD FAILED (total time: 5 seconds)
  </code></pre>
  
  <p>The code I use is the following;</p>
  
  <pre><code>package Labb2;
  
  import java.util.Scanner;
  
  public class BMI {
  
      public static void main(String[] args) {
  
          Scanner viktObj = new Scanner(System.in);
          Scanner langdObj = new Scanner(System.in); 
  
          double vikt;
          double langd;
          double bmi;
  
          System.out.print("Ange din vikt: ");
          vikt = viktObj.nextDouble();
  
          System.out.print("Ange din längd i meter (ex. 1.70): ");
          langd = langdObj.nextDouble();
  
          bmi = vikt / (langd * langd);
          System.out.printf("Ditt BMI är: %.2f", bmi);
          System.out.println("");
  
  
      }
  
  }
  </code></pre>