How do I read numbers in exponential format in Java?
[*] The program below (written by Steve Chapel) uses StreamTokenizer to read data from the standard input and recognizes doubles in exponential format (e.g. -1.23e-45). import java.io.*; public class ReadExponential { public static void main(String argv[]) { DataInputStream in = new DataInputStream(System.in); StreamTokenizer st = new StreamTokenizer(in); try { while (st.nextToken() != StreamTokenizer.TT_EOF) { switch (st.ttype) { case StreamTokenizer.TT_NUMBER: double num = st.nval; int exp = 0; st.ordinaryChars(‘\0’, ‘ ‘); st.nextToken(); st.whitespaceChars(‘\0’, ‘ ‘); if (st.ttype == StreamTokenizer.TT_WORD && Character.toUpperCase(st.sval.charAt(0)) == ‘E’) { try { exp = Integer.parseInt(st.sval.substring(1)); } catch (NumberFormatException e) { st.pushBack(); } } else if (st.ttype < 0 || st.ttype > ‘ ‘) st.pushBack(); System.out.println(“Num ” + num * Math.pow(10, exp)); break; case StreamTokenizer.TT_WORD: System.out.println(“Word ” + st.sval); break; default: System.out.println(