Would final String charData = "6.67E-2"; work?
Sure. Scientific notation works as input.
Scientific notation is a way of using characters to express a number. When it is converted to a double you get the same double that you would get with ordinary notation. ("6.67E-2" converts to the same double that "0.00667" converts to). Here is the program again. But now it reads input from the keyboard.
import java.io.*;
class InputToDouble
{
public static void main (String[] args) ___________________________
{
String charData;
double value;
__________________________________
__________________________________
__________________________________
value = Double.parseDouble( charData ) ;
System.out.println("value: " + value +" twice value: " + 2*value );
}
}
|
Unfortunately, the program is not complete. These are the missing parts, but not in order:
System.out.println("Enter a double:");
BufferedReader stdin = new BufferedReader ( new InputStreamReader( System.in ) );
charData = stdin.readLine();
throws IOException