import java.io.*;

/**
 * Utility class: functions for console input.
 *
 * @author   Andreas Noack
 * @version  2004-01-19
 */
public class In {

    // Prevents instantiation.
    private In() {};

    /**
     * Reads a line from <code>System.in</code>.
     * @param prompt String to print to <code>System.out</code> before reading.
     * @return Line read from <code>System.in</code>.
     */
    public static String readString(String prompt) {
        BufferedReader stdin = 
            new BufferedReader(new InputStreamReader(System.in));
        String res = new String();
        boolean error = false;
        do {
            error = false;
            System.out.print(prompt);
            try {
                res = stdin.readLine();
            } catch(Exception e) {
                System.out.println(e);      
                error = true;
            }
        } while (error);
        return res;
    }

    /**
     * Repeats reading a line from <code>System.in</code>
     *   until the conversion of the line to an <code>int</code> succeeds.
     * @param prompt String to print to <code>System.out</code> before reading.
     * @return Line read from <code>System.in</code>.
     */
    public static int readInt(String prompt) {
        BufferedReader stdin = 
            new BufferedReader(new InputStreamReader(System.in));
        int res = 0;
        boolean error = false;
        do {
            error = false;
            System.out.print(prompt);
            try {
                res = Integer.parseInt(stdin.readLine());
            } catch(Exception e) {
                System.out.println(e);
                error = true;
            }
        } while(error);
        return res;
    }

    /**
     * Repeats reading a line from <code>System.in</code>
     *   until the conversion of the line to a <code>float</code> succeeds.
     * @param prompt String to print to <code>System.out</code> before reading.
     * @return Line read from <code>System.in</code>.
     */
    public static float readFloat(String prompt) {
        BufferedReader stdin = 
            new BufferedReader(new InputStreamReader(System.in));
        float res = 0.0f;
        boolean error = false;
        do {
            error = false;
            System.out.print(prompt);
            try {
                res = new Float(stdin.readLine()).floatValue();
            } catch(Exception e) {
                System.out.println(e);
                error = true;
            }
        } while(error);
        return res;
    }


    /**
     * Example application.
     */
    public static void main(String[] args) {
        String s = In.readString("Input a string: ");
        int i = In.readInt("Input an integer: ");
        float f = In.readInt("Input a float: ");
        
        System.out.println("You input the string " + s + ", ");
        System.out.println("the integer " + i + ", and ");
        System.out.println("the float " + f + ".");
    }

}
