// Load Java's I/O facilities: import java.io.*; public class p2FindMin { // $main$ must "throw" an exception if input is illegal: public static void main(String[] args) throws IOException { // Create object $in$ that allows you to prompt user for input: BufferedReader in = new BufferedReader (new InputStreamReader(System.in)); // Read strings: System.out.print("Enter your name: "); String s = in.readLine(); System.out.println("Welcome, "+s+"!"); // Enter integer: System.out.print("Enter an integer: "); int value1 = Integer.parseInt(in.readLine()); // Enter double: System.out.print("Enter a double: "); double value2 = Double.valueOf(in.readLine()).doubleValue(); // Find minimum value: double min; if (value1 <= value2) min = value1; else min = value2; // Report in correct format: // + If integer, report as integer // + otherwise, leave as double if ( min % (int) min == 0 ) System.out.println("The minimum value is: "+(int)min); else System.out.println("The minimum value is: "+min); } }