Assignment #74 and Safe Square Root

Code

    ///Name: Tim Gibson
    ///Period: 6
    ///Project Name: Safe Square Root
    ///File Name: SquareRoot.java
    ///Date Finished: 10/26/15
        
    import java.util.Scanner;
    
    public class SquareRoot
    {
        public static void main ( String[] args )
        {
            Scanner keyboard = new Scanner(System.in);
            
            int n;
            double a;
            
            System.out.print( "SQUARE ROOT! \nEnter a number: " );
            n = keyboard.nextInt();
            
            while ( n < 0 )
            {
                System.out.println( "You can't take the square root of a negative number." );
                System.out.print( "Try again: " );
                n = keyboard.nextInt();
            }
            
            a = Math.sqrt(n);
            
            System.out.println( "The square root of " + n + " is " + a + "." );
            
        }
    }
        

Picture of the output

Assignment74