/********************************
* CS239 Section 1
* Lab 4
* Jeremy Blanchette
* Instructor: Professor Adams
* 1-22-07
********************************/

import java.util.*;
import java.io.*;
/*************************************
 * Purpose: prompts user for a number
 * then outputs the square root
 ************************************/
public class IO_blanchje_Rooter
{

	/**********************************
	 * Runs the whole program
	 * @params : args, unused
	 **********************************/
    public static void main(String[] args)
    {
       double          value, result;       
       PrintWriter     screen;       
       Scanner         keyboard;
       
       screen   = new PrintWriter(System.out); //creates a new printwriter object called screen
       keyboard = new Scanner(System.in); //creates a new scanner object called keyboard

       screen.println("Enter a number: ");    //prompts user for a number
       screen.flush(); // flushes screen and shows on monitor
       
       while (keyboard.hasNext())
		 
       {
          value = keyboard.nextDouble(); //puts value of keyboard into value
          result = Math.sqrt(value); //takes the square root of value and puts it in result

          screen.printf("The square root of " + value + " is " + result);
          screen.flush(); //prints out result
          
          screen.println("Enter a number: ");       
        	 screen.flush(); //reprompts
       }

       screen.println("Done.\n");       
       screen.flush();//tells the user the program terminated normally
    }
    
}
