How can I read a double variable from keyboard in Java? I\'m trying to solve this, but it didn\'t works. It said:
Exception in thread \"main\" java.util.I
try this:
import java.io.*;
import java.util.Scanner;
class DoubleDouble
{
public static void main (String[] args)
{
double value;
Scanner scan = new Scanner( System.in );
System.out.print("Enter a double:");
value = scan.nextDouble();
System.out.println("value: " + value +" twice value: " + 2.0*value );
}
}
And be sure, that you type: For example: 3.14 so the dot, should be a point