// IntegerMinAndMax.java class IntegerMinAndMax { public static void main(String[] args) { // declare the integer variables int x, y, min, max; // read in the values for x and y System.out.print("Enter an integer value: "); x = readInt(); System.out.print("Enter another integer value: "); y = readInt(); // compute their min and max min = Math.min(x,y); max = Math.max(x,y); // print out their min and max System.out.print("The smaller number is: "); System.out.println(min); System.out.print("The larger number is: "); System.out.println(max); } /////////////////////////////////// // readString, readInt, readDouble /////////////////////////////////// public static String readString() { java.io.InputStreamReader isr = new java.io.InputStreamReader(System.in); java.io.BufferedReader d = new java.io.BufferedReader(isr); try { return d.readLine(); } catch (Exception e) { return "error"; } } public static int readInt() { return Integer.parseInt(readString()); } public static double readDouble() { return Double.valueOf(readString()).doubleValue(); } }