0

I am doing some small pratice using java language and stuck with these:

import java.util.Scanner;
public class nhap {
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        double n;
        n= sc.nextDouble();
        System.out.println(1.0/n);
    }
}

when I try to enter a number of type double . It shows me this error:

0.56
Exception in thread "main" java.util.InputMismatchException
    at java.base/java.util.Scanner.throwFor(Unknown Source)
    at java.base/java.util.Scanner.next(Unknown Source)
    at java.base/java.util.Scanner.nextDouble(Unknown Source)
    at nhap.nhap.main(nhap.java:10)

I'm looking for some advice that help me solve this problem :)

TamTam
  • 547
  • 1
  • 5
  • 16

0 Answers0