import java.io.PrintWriter;
import java.util.Scanner;
/************************************************
 * Lab 4 - Rooter gets a number value, calculates and
 *    displays its square root
 * 
 * @author - Joshua M. Bryant
 * @version - V1 - Jan 22, 2007
 ************************************************/
 // Lab Time : Wednesday, 1:25 - Section 1
 // Lab 4 : Experimenting With File I/O

public class IO_bryan5jm_Rooter
{
   /**********************************************
    * main method that gets a number value, calculates
    * and displays its square root
    * 
    * @param args not used
    **********************************************/
   public static void main(String[] args)
   {
      double          value, result;       
      PrintWriter     screen;       
      Scanner         keyboard;
      
      screen   = new PrintWriter(System.out);       
      keyboard = new Scanner(System.in);
      
		// prompts user to enter a number
	   screen.println("Enter a number: ");    
      screen.flush();
      
		// loops storing number, calculating and printing square root, and
		//    prompting for next number
      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();
      }
		
		// prints if program ends normally
      screen.println("Done.\n");
      screen.flush();
   }    
}
