/**
 * @author:  Christian Blümke
 * @version:  2.4.1final
 * @date:  May15-1999
 *
 * Geaendert von Andreas Noack 2002-04-05:
 *   In allen (get)-Methoden Ausgabe "? " nach (whatIsIt) entfernt.
 */
import java.io.*;

public class stdin
{
   public static void version()
   {
      System.out.println("Class 'stdin' of package 'dssz.io', version 2.4.1 " +
      "by Chistian Blümke.");
   }

   static LineNumberReader stdin = new LineNumberReader
      (new InputStreamReader(System.in));

   static void err(String message, String limit1, String limit2)
   {
      System.out.println("Fehleingabe! " + message + "\n" +
      "(Zulässiger Bereich: " + limit1 + " bis " + limit2 + ")\n");
   }

   static void err2(String message)
   {
      System.out.println("Fehleingabe! " + message + "\n");
   }

   static void errUn()
   {
      System.out.println("Unbekannter Fehler!\n");
   }

   public static String getString(String whatIsIt)
   {
      boolean error = false;
      String res = new String();
      do
      {
         error = false;
         try
         {
            System.out.print(whatIsIt);
            res = stdin.readLine();
            if(res.length() == 0)
            {
               err2("Es wurde KEIN Zeichen eingelesen.");
               error = true;
            }
         }
         catch(Exception e)
         {
            error = true;
            errUn();
         }
      }
      while(error);
      return res;
   }

   public static char getChar(String whatIsIt)
   {
      char res;
      boolean error = false;
      String in = new String();
      do
      {
         error = false;
         try
         {
            System.out.print(whatIsIt);
            in = stdin.readLine();
            if(in.length() != 1)
            {
               err2("Nur EIN Zeichen ist erlaubt.");
               error = true;
            }
         }
         catch(Exception e)
         {
            errUn();
            error = true;
         }
      }
      while(error);
      res = in.charAt(0);
      return res;
   }

   public static int getPosInt(String whatIsIt)
   {
      int res = 0;
      boolean error = false;
      do
      {
         error = false;
         try
         {
            System.out.print(whatIsIt);
            res = Integer.parseInt(stdin.readLine());
         }
         catch(Exception e)
         {
            error = true;
         }
         if(((!error) && (res < 0)) || (error))
         {
            error = true;
            err("Dies ist KEINE positive Integerzahl!","0","2.147.483.647");
         }
      }
      while(error);
      return res;
   }

   public static int getPosIntNotZero(String whatIsIt)
   {
      int res = 0;
      boolean error = false;
      do
      {
         error = false;
         try
         {
            System.out.print(whatIsIt);
            res = Integer.parseInt(stdin.readLine());
         }
         catch(Exception e)
         {
            error = true;
         }
         if(((!error) && (res < 1)) || (error))
         {
            error = true;
            err("Dies ist KEINE gültige positive " +
            "Integerzahl!","1","2.147.483.647");
         }
      }
      while(error);
      return res;
   }

   public static int getInt(String whatIsIt)
   {
      int res = 0;
      boolean error = false;
      do
      {
         error = false;
         try
         {
            System.out.print(whatIsIt);
            res = Integer.parseInt(stdin.readLine());
         }
         catch(Exception e)
         {
            error = true;
            err("Dies ist KEINE Integerzahl!",
            "-2.147.483.648","2.147.483.647");
         }
      }
      while(error);
      return res;
   }

   public static byte getByte(String whatIsIt)
   {
      byte res = 0;
      boolean error = false;
      do
      {
         error = false;
         try
         {
            System.out.print(whatIsIt);
            res = Byte.parseByte(stdin.readLine());
         }
         catch(Exception e)
         {
            error = true;
            err("Dies ist KEINE Bytezahl!","-128","127");
         }
      }
      while(error);
      return res;
   }

   public static short getShort(String whatIsIt)
   {
      short res = 0;
      boolean error = false;
      do
      {
         error = false;
         try
         {
            System.out.print(whatIsIt);
            res = Short.parseShort(stdin.readLine());
         }
         catch(Exception e)
         {
            error = true;
            err("Dies ist KEINE Zahl im Short-Format!",
            "-32.768","32.767");
         }
      }
      while(error);
      return res;
   }

   public static long getLong(String whatIsIt)
   {
      long res = 0;
      boolean error = false;
      do
      {
         error = false;
         try
         {
            System.out.print(whatIsIt);
            res = Long.parseLong(stdin.readLine());
         }
         catch(Exception e)
         {
            error = true;
            err("Dies ist KEINE Zahl im Long-Format!",
            "~ -9 * 10^18","~ 9 * 10^18");
         }
      }
      while(error);
      return res;
   }

   public static float getFloat(String whatIsIt)
   {
      float res = 0;
      boolean error = false;
      do
      {
         error = false;
         try
         {
            System.out.print(whatIsIt );
            res = new Float(stdin.readLine()).floatValue();
         }
         catch(Exception e)
         {
            error = true;
            err2("Dies ist KEINE Zahl im Float-Format!");
         }
      }
      while(error);
      return res;
   }

   public static double getDouble(String whatIsIt)
   {
      double res = 0;
      boolean error = false;
      do
      {
         error = false;
         try
         {
            System.out.print(whatIsIt);
            res = new Double(stdin.readLine()).doubleValue();
         }
         catch(Exception e)
         {
            error = true;
            err2("Dies ist KEINE Zahl im Double-Format!");
         }
      }
      while(error);
      return res;
   }

}
