title: Scanner double value - InputMismatchException
body: <p>I tried use scanner at easiest way:</p>
  
  <p><strong>Code:</strong></p>
  
  <pre><code>double gas, efficiency, distance, cost;
  Scanner scanner = new Scanner(System.in);
  
  System.out.print("Enter the number of gallons of gas in the tank: ");
  gas = scanner.nextDouble();
  System.out.print("Enter the fuel efficiency: ");
  efficiency = scanner.nextDouble();
  </code></pre>
  
  <p>But after first input <code>5.1</code> it throws:</p>
  
  <pre><code>Exception in thread "main" java.util.InputMismatchException
      at java.util.Scanner.throwFor(Scanner.java:909)
      at java.util.Scanner.next(Scanner.java:1530)
      at java.util.Scanner.nextDouble(Scanner.java:2456)
      at udacity.MileagePrinter.main(MileagePrinter.java:59)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:601)
      at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
  </code></pre>
  
  <p>The <a href="http://docs.oracle.com/javase/6/docs/api/java/util/InputMismatchException.html" rel="noreferrer">JavaDocs</a> state: </p>
  
  <blockquote>
    <p>Thrown by a Scanner to indicate that the token retrieved does not match the<br>
        pattern for the expected type, or that the token is out of range for the expected type.</p>
  </blockquote>
  
  <p>But to my mind all look correctly, and should work OK.</p>
  
  <p><strong>Questions:</strong></p>
  
  <ul>
  <li>Why this happen at this situation?   </li>
  <li>How to circumvent this trouble?</li>
  </ul>