 //Import the necessary java packages
 import java.io.*;
import java.util.Scanner;

/**********************************************
* This lab is experimenting with Input and Output from files
* @author - Michael Beaumont  & Elizabeth Adams
* @version - VI - 1/22/07
* Section 1
* Lab 4
************************************************/

public class IO_beaumomw_Rooter
{

/**************************************************
*  This is the main method where the variables are declared and instantiated and this is from 
*  where the program actions are run
* @param args this is the command line input
***************************************************/
    public static void main(String[] args)
    {
	 //declare variables
       double          value, result;       
       PrintWriter     screen;       
       Scanner         keyboard;
     
	 //instantiate the variables that are declared above  
       screen   = new PrintWriter(System.out);       
       keyboard = new Scanner(System.in);
		 		 
		 
		 screen.println("Enter a number: ");  //get a number to find the square root of  
		 screen.flush();  //flushes the stream
       		 		 
      //This while loop takes in a number, takes the square root of a number and outputs this to the user.
		//This loop will run until the Scanner no longer has another token in it's input
		 while (keyboard.hasNext())
       {
          value = keyboard.nextDouble(); 
          result = Math.sqrt(value);  //take the square root of the number

          screen.printf("The square root of " + value + " is " + result);  //Echo the input along with giving the correct output
          screen.flush();  //flushes the stream
          
          screen.println("Enter a number: ");   //get another number from the user  
        	 screen.flush();  //flushes the stream
       }

       screen.println("Done.\n");     //Displayed when no token is in the input and the loop has been exited
       screen.flush();  //flushes the stream
    }
    
}
