/**
 * A class for reading in base types from stdin
 * @author Lisa Meeden
 */
import java.io.*;

class SimpleIO {
    static BufferedReader keybd = 
	new BufferedReader(new InputStreamReader(System.in));

    static double readDouble() {
	String line;
	boolean ok = false;
	double d = 0;
	while (!ok) {
	    try {
		if ((line = keybd.readLine()) != null)
		    d = Double.valueOf(line).doubleValue();
		ok = true;
	    }
	    catch (NumberFormatException e) {
		System.out.println("Invalid double, try again:");
	    }
	    catch (IOException e) {
	    }
	}
	return d;
    }

    static int readInt() {
	String line;
	boolean ok = false;
	int i = 0;
	while (!ok) {
	    try {
		if ((line = keybd.readLine()) != null)
		    i = Integer.valueOf(line).intValue();
		ok = true;
	    }
	    catch (NumberFormatException e) {
		System.out.println("Invalid int, try again:");
	    }
	    catch (IOException e) {
	    }
	}
	return i;
    }
	
    static String readString() {
	String line = "";
	try {
	    line = keybd.readLine();
	}
	catch (IOException e) {
	}
	return line;
    }
	
    public static void main(String[] args) throws IOException {
	double d1, d2, sum;
	int i1, i2, product;
	String s1, s2;

	System.out.println("Input two doubles: ");
	d1 = readDouble();
	d2 = readDouble();
	sum = d1 + d2;
	System.out.println("Their sum is: " + sum);

	System.out.println("Input two integers: ");
	i1 = readInt();
	i2 = readInt();
	product = i1 * i2;
	System.out.println("Their product is: " + product);

	System.out.println("Enter two strings: ");
	s1 = readString();
	s2 = readString();
	System.out.println("Thier concatenation is: " + s1 + s2);
    }
}
