import java.io.PrintWriter;
import java.util.Scanner;

/*******************************************************************
 * This program lets us use Java APIs to find what problems are, 
 * and how to solve it, like what is PrintWriter, how to use it, 
 * and how to read an double number in, etc.
 *
 * @author Lu Tian modifies Prof. Adam's code
 * @version 3
 *******************************************************************/
 // Date: January 17, 2007
 // Section 1
 // Lab 4
public class IO_tianlx_Rooter
{
  	/**
	 * The main() method will take an double number from user,
	 * and count the square root of this number.
	 *
	 * @param args		Command line (unused in this program)
	 **/  
	 public static void main(String[] args)
    {
       // Declarations
		 double          value, result;       
       PrintWriter     screen;       
       Scanner         keyboard;
       
       // Instantiate the variables
		 screen   = new PrintWriter(System.out);       
       keyboard = new Scanner(System.in);
		 
		 //Prompt to user to get a number.
       screen.println("Enter a number: ");    
       screen.flush();
       
		 //To check if user has entered a number
		 //If user keeps enter, and there will be never end this loop.
       while (keyboard.hasNext())
       {
          value = keyboard.nextDouble();
          result = Math.sqrt(value);

          screen.printf("The square root of " + value + " is " + result);
          screen.flush();
          
          screen.println("Enter a number: ");       
        	 screen.flush();
       } //end while loop

       screen.println("Done.\n");       
       screen.flush();
    } //end main()
} //end class
