Assignment #74 Safe Square Root

Code

    
    /// Name: Lacey Reese 
    /// Period: 5
    /// Program Name:  SafeSquareRoot
    /// File Name:  SafeSquareRoot.java
    /// Date Finished 1/26/2016
    

    import java.util.Scanner;
    
    public class SafeSquareRoot 
    {
        
        public static void main( String[] args ) 
        {
            
            Scanner keyboard = new Scanner(System.in);
            
            int x;
            
            System.out.println( "SQUARE ROOT!" );
            
            System.out.print( "Enter a number: " );
            x = keyboard.nextInt();
            double sr = Math.sqrt(x); 
            
            while ( x <= 0 )
            {
            System.out.println( "You can't take the square root of a negative number, silly." );
            System.out.print( "Try again: " );
            x = keyboard.nextInt();
            sr = Math.sqrt(x); 
            }
            
            System.out.println( "The square root of " + x + " is " + sr + "." );
            
        }
    }
    

    

Picture of the output

// Assignment 74