I just started my university course in java and keep getting this error with the Scanner class.
import java.util.Scanner;
public class InchConversion
{
public static void main (String[] args)
{
Double inches, centimeters;
Scanner fromKeyboard = new Scanner(System.in);
System.out.println("Enter Value in Inches");
inches = fromKeyboard.nextDouble();
centimeters = inches*2.54;
System.out. println(inches + " inches is equal to " + centimeters + " centimeters.");
}
}
and the error I keep getting is:
Compiling InchConversion.java.......
-----------OUTPUT-----------
Enter Value in Inches
Exception in thread "main" java.util.NoSuchElementException
at java.util.Scanner.throwFor(Scanner.java:862)
at java.util.Scanner.next(Scanner.java:1485)
at java.util.Scanner.nextDouble(Scanner.java:2413)
at InchConversion.main(InchConversion.java:11)
[Finished in 0.8s with exit code 1]