// Simple input from the keyboard for all primitive types.
// Copyright (c) Peter van der Linden,  May 5 1997.
// Feel free to use this in your programs, as long as this
// comment stays intact.
//
// This is not thread safe, not high performance, and doesn't tell EOF.
// It's intended for low-volume easy keyboard input.
// An example of use is:
//     EasyIn easy = new EasyIn();
//     int i = easy.readInt();   // reads an int from System.in

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

class EasyIn
   {
   static InputStreamReader is = new InputStreamReader( System.in );
   static BufferedReader br = new BufferedReader( is );
   StringTokenizer st;

   StringTokenizer getToken() throws IOException {
      String s = br.readLine();
      return new StringTokenizer( s );
   }

   boolean readBoolean()
      {
      try
         {
         st = getToken();
         return new Boolean(st.nextToken()).booleanValue();
         }
      catch ( IOException ioe )
         {
         err.println( "IOException in EasyIn.readBoolean" );
         return false;
         }
      }

   byte readByte()
      {
      try
         {
         st = getToken();
         return Byte.parseByte( st.nextToken() );
         }
      catch ( IOException ioe )
         {
         err.println( "IOException in EasyIn.readByte" );
         return 0;
         }
      }

   short readShort()
      {
      try
         {
         st = getToken();
         return Short.parseShort( st.nextToken() );
         }
      catch ( IOException ioe )
         {
         err.println( "IOException in EasyIn.readShort" );
         return 0;
         }
      }

   int readInt()
      {
      try
         {
         st = getToken();
         return Integer.parseInt( st.nextToken() );
         }
      catch ( IOException ioe )
         {
         err.println( "IOException in EasyIn.readInt" );
         return 0;
         }
      }

   long readLong()
      {
      try
         {
         st = getToken();
         return Long.parseLong( st.nextToken() );
         }
      catch ( IOException ioe )
         {
         err.println( "IOException in EasyIn.readFloat" );
         return 0L;
         }
      }

   float readFloat()
      {
      try
         {
         st = getToken();
         return new Float( st.nextToken() ).floatValue();
         }
      catch ( IOException ioe )
         {
         err.println( "IOException in EasyIn.readFloat" );
         return 0.0F;
         }
      }

   double readDouble()
      {
      try
         {
         st = getToken();
         return new Double( st.nextToken() ).doubleValue();
         }
      catch ( IOException ioe )
         {
         err.println( "IOException in EasyIn.readDouble" );
         return 0.0;
         }
      }

   char readChar()
      {
      try
         {
         String s = br.readLine();
         return s.charAt( 0 );
         }
      catch ( IOException ioe )
         {
         err.println( "IOException in EasyIn.readChar" );
         return 0;
         }
      }

   String readString()
      {
      try
         {
         return br.readLine();
         }
      catch ( IOException ioe )
         {
         err.println( "IO Exception in EasyIn.readString" );
         return "";
         }
      }

   // This method is just here to test the class
   public static void main (String args[])
      {
      EasyIn easy = new EasyIn();

      out.print( "enter char: " ); out.flush();
      out.println( "You entered: " + easy.readChar() );

      out.print( "enter String: " ); out.flush();
      out.println( "You entered: " + easy.readString() );

      out.print( "enter boolean: " ); out.flush();
      out.println( "You entered: " + easy.readBoolean() );

      out.print( "enter byte: " ); out.flush();
      out.println( "You entered: " + easy.readByte() );

      out.print( "enter short: " ); out.flush();
      out.println( "You entered: " + easy.readShort() );

      out.print( "enter int: " ); out.flush();
      out.println( "You entered: " + easy.readInt() );

      out.print( "enter long: " ); out.flush();
      out.println( "You entered: " + easy.readLong() );

      out.print( "enter float: " ); out.flush();
      out.println( "You entered: " + easy.readFloat() );

      out.print( "enter double: " ); out.flush();
      out.println( "You entered: " + easy.readDouble() );
      }

   }