// Written by: Darren Gates & Ray Klefstad // Date: January 2000 // School: U.C. Irvine import java.io.*; public class NumericInputExample { public static void main(String argv[]) throws IOException { try { // get input and convert to a String byte [] myInput = new byte[30]; System.out.print("Type a number: "); System.in.read(myInput); String myOutput = new String(myInput); // convert the String to a double Double d = new Double(myOutput); double result = d.doubleValue(); // perform calculation and display result = result * 2; System.out.println("Twice that amount is: " + result); } catch (NumberFormatException e) { System.out.println("That's not a number!"); } } }