package simpleIO;

import java.io.*;
import java.text.*;

public class Reader
{
	
	// Reads a double from the keyboard and returns it to the calling method.
	public static double readDouble ()
	{
		double num;
		BufferedReader stdin = new BufferedReader (new InputStreamReader (System.in));
		try
		{
			num = Double.valueOf (stdin.readLine ()).doubleValue ();
		} catch (IOException e) 
		{ num = 0;}
		return num;

	} // private static double readDouble ()	
	
	// Formats a double for string output with two decimal places.
	public static String decimals (double num)
	{
		DecimalFormat decFor = new DecimalFormat (); 
		decFor.setMaximumFractionDigits (2); 
		decFor.setMinimumFractionDigits (2);
		return decFor.format (num);
	} // private String decimals (double num)
		
	// Reads an integer from the keyboard and returns it to the calling method.
	public static int readInteger ()
	{
		int num;
		BufferedReader stdin = new BufferedReader 
			(new InputStreamReader (System.in));	
		try
		{
			num = Integer.parseInt (stdin.readLine ());
			
		}	catch (IOException e)
		{	num = 0;}
		return num;
		
	} // public static int readInteger ()
	
	// Reads a string from the keyboard and returns it to the calling method.
	public static String readString ()
	{
		String str;
		BufferedReader stdin = new BufferedReader 
			(new InputStreamReader (System.in));	
		try
		{
			str = stdin.readLine ();
			
		}	catch (IOException e)
		{	str = "";}
		return str;
		
	} // public static int readString ()
	
} // public class Reader
