There is an error when I enter the double next value with a point like (1.5) I don't know why?
Even when I put (1,5) with the comma, the same result is wrong.
Can anyone help me fix it?
import java.util.Scanner;
public class ex1 {
public static void main(String[] args) {
Scanner scan = new Scanner (System.in);
double inch;
System.out.println("write the distance in inch:");
inch = scan.nextDouble();
System.out.println("the result is " + inch * 2.54 + " cm");
}
}
the output:
write the distance in inch:
1.5
Exception in thread "main" java.util.InputMismatchException
at java.base/java.util.Scanner.throwFor(Scanner.java:943)
at java.base/java.util.Scanner.next(Scanner.java:1598)
at java.base/java.util.Scanner.nextDouble(Scanner.java:2569)
at ex1.main(ex1.java:10)
Process finished with exit code 1