It might be locale dependent. Decimal numbers are e.g written as 0,5 in Sweden.
Change your code so that it says e.g.:
Scanner scan = new Scanner(System.in);
scan.useLocale(Locale.US);
More Related Contents:
- Conditional Statement on Java7
- How to use java.util.Scanner to correctly read user input from System.in and act on it?
- Validating input using java.util.Scanner [duplicate]
- What’s the difference between next() and nextLine() methods from Scanner class?
- How to handle infinite loop caused by invalid input (InputMismatchException) using Scanner
- How can I read input from the console using the Scanner class in Java?
- How to use Scanner to accept only valid int as input
- java.util.NoSuchElementException: No line found
- Scanner vs. StringTokenizer vs. String.Split
- Scanner NoSuchElementException
- Reading a .txt file using Scanner class in Java
- Java Multiple Scanners
- Scanner method to get a char
- Exception in thread “main” java.util.NoSuchElementException
- How can i handle it with scanner (java)?
- Java: Infinite loop using Scanner in.hasNextInt()
- Scanner only reads file name and nothing else
- Read next word in java
- Java — Closing Scanner and Resource Leak
- Scanner only reads first word instead of line
- Can’t use Scanner.nextInt() and Scanner.nextLine() together [duplicate]
- What does scanner.close() do?
- Java using scanner enter key pressed
- Getting User input with Scanner
- How to use .nextInt() and hasNextInt() in a while loop
- Scanner skipping every second line from file [duplicate]
- How to read a text file directly from Internet using Java?
- Java Scanner doesn’t wait for user input [duplicate]
- Why is hasNext() False, but hasNextLine() is True?
- Weird behaviour with Scanner#nextFloat