import java.io.*;

public class Lire
{
	// Cette fonction permet de saisir au clavier une variable de type String
    public static String chaine()
    {
	    String tmp = "";
	    char C='\0';
		try 
		{
			while ((C=(char) System.in.read()) !='\n')
			{
				if (C != '\r')  tmp = tmp+C;
		 
			}
		}
		catch (IOException e)
		{
			System.out.println("Erreur de frappe");
			System.exit(0);
		}
		return tmp;
    } 

	// Cette fonction permet de saisir au clavier une variable entière de type byte
	public static byte entierByte()  
	{
		byte x=0;
		try 
		{
			x = Byte.parseByte(chaine());
		}
		catch (NumberFormatException e) 
		{
			System.out.println("Format numérique incorrect");
			System.exit(0);
		}	
		return x ;
	}

	// Cette fonction permet de saisir au clavier une variable entière de type Short
	public static short entierShort()
	{
		short x=0;
		try 
		{
			x=Short.parseShort(chaine());
		}
		catch (NumberFormatException e) 
		{
			System.out.println("Format numérique incorrect");
			System.exit(0);
		}	
		return x ;
	 }

	// Cette fonction permet de saisir au clavier une variable entière de type int
	public static int entierInt()  
	{
		int x=0;
		try 
		{
			x=Integer.parseInt(chaine());
		}
		catch (NumberFormatException e) 
		{
			System.out.println("Format numérique incorrect");
			System.exit(0);
		}	
		return x ;
	 }
	
	// Cette fonction permet de saisir au clavier une variable entière de type long
	public static long entierLong() 
	{
		long x=0;
		try 
		{
			x=Integer.parseInt(chaine());
		}
		catch (NumberFormatException e) 
		{
			System.out.println("Format numérique incorrect");
			System.exit(0);
		}	
		return x ;
	 }

	 // Cette fonction permet de saisir au clavier une variable  réelle  double
	public  static double reelDouble()
	{
		double x=0.0;
		try 
		{
			x=Double.valueOf(chaine()).doubleValue();
		}
		catch (NumberFormatException e) 
		{
			System.out.println("Format numérique incorrect");
			System.exit(0);
		}	
		return x ;
	 }
	 
	// Cette fonction permet de saisir au clavier une variable  réelle  float
	public  static float reelFloat()
	{
		float x=0.0f;
		try 
		{
			x=Double.valueOf(chaine()).floatValue();
		}
		catch (NumberFormatException e) 
		{
			System.out.println("Format numérique incorrect");
			System.exit(0);
		}	
		return x ;
	}
	
	// Cette fonction permet de saisir au clavier une variable  de type char
	public  static char caractere()  
	{
		String tmp=chaine();
		if (tmp.length()==0)
		{
			return '\n';
		}
		else 
		{
			return tmp.charAt(0);
		}
	}
}

