/*
 *Created by: 	C. Whittington
 *Date: 		October 31 2003
 *Purpose:		This program shows simple input from the console
 *				screen in java.
 */

/* 
 *java.io.* must be imported to allow the use of InputStreamReader
 *and BufferedReader
 */
import java.io.*;
class ReadConsole 
{
        /*
         *The InputStreamReader has some error checking built in to
         *it.  If there is an error when trying to read from the 
         *console the InputStreamReader creates an IOException.
         *The IOException can either be 'thrown' or 'caught.'
         *When we throw an Exception in main it means that we are going to
         *ignore the error (this is a simplistic explaination).  If we where
         *to catch the error we could use it to make sure that the input entered
         *the program properly.  To throw the Exception we use the line:
         *throws java.io.IOExeption
         */
        public static void main(String [] args) throws java.io.IOException 
        {
                // An InputStreamReader is an object that allows use to get
                // information from the console screen.
                InputStreamReader isr=new InputStreamReader(System.in);
                
                // The BufferedReader is an object that helps the
                // InputStreamReader get information from the console more
                // efficiently.
                BufferedReader br=new BufferedReader(isr);
                
                // This string will be used to hold the users input.
                String input;
                
             	
             	// Prompts the user for a number.
             	System.out.print("Please enter a whole number : ");   
               
                // br.readLine() get the users input from the console screen.
                // That input is then saved in the string called input.
                input=br.readLine();
                
                // To see what was inputted we will print the input back to the
                // console.
                System.out.println("Got: " +input);
                
                // The final thing that is often helpful when dealing with user
                // input is being able to convert a string which is inputted to
                // an integer.
                int x;
                
                // Integer.parseInt is a command that converts a string (in this
                // case 'input') to an integer.  The variable 'x' is assigned
                // the converted value.
                x=Integer.parseInt(input);
                
                // Prints the value of x.
                System.out.println("Parsed: " +x);
        }
}
