import java.io.*;
import java.util.Scanner;
/*******************************************************************
 * This program uses printWriter and Scanner to take in numbers from
 * the user and calculates the square root of the numbers until the 
 * user terminates the program.  
 *
 * @author - Trevor Caudill 
 * @version - V1 - 1/22/07
 * Lab time: MW 1:25-2:15
 * Section 1
 * Lab 4
 *****************************************************************/
public class IO_caudiltt_Rooter
{
    public static void main(String[] args)
    {
       double          value, result;       
       PrintWriter     screen;       
       Scanner         keyboard;
       
       screen   = new PrintWriter(System.out);       
       keyboard = new Scanner(System.in);

		// promts user to enter a number.
       screen.println("Enter a number: ");   
		 screen.flush(); 
       
       // while loop runs until the stream has ended.
		 // takes the square root of a number and prints the results.
		 while (keyboard.hasNext())
       {
          value = keyboard.nextDouble();
          result = Math.sqrt(value);

          screen.printf("The square root of " + value + " is " + result);
          screen.flush();
          
			 // then reprompt the user for a number.
          screen.println("Enter a number: ");       
        	 screen.flush();
       }

       screen.println("Done.\n");       
       screen.flush();
    }// end main
    
}// end Rooter class
