/** * Title: Chapter 2, "Primitive Data Types and Operations" * Description: Examples for Chapter 2 * Copyright: Copyright (c) 2000 * Company: Armstrong Atlantic State University * @author Y. Daniel Liang * @version 1.0 */ // MyInput.java: Contain the methods for reading int, double, and // string values from the keyboard import java.io.*; public class MyInput { /**Read a string from the keyboard*/ public static String readString() { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); // Declare and initialize the string String string = " "; // Get the string from the keyboard try { string = br.readLine(); } catch (IOException ex) { System.out.println(ex); } // Return the string obtained from the keyboard return string; } /**Read an int value from the keyboard*/ public static int readInt() { return Integer.parseInt(readString()); } /**Read a double value from the keyboard*/ public static double readDouble() { return Double.parseDouble(readString()); } }