Assignment #74

Code

    ///Name: Cody Swain
    ///Period: 6
    ///Project Name: SafeSquareRoot
    ///File Name: SafeSquareRoot.java
    ///Date: 1/6/16
    
    import java.util.Scanner;
    
    public class SafeSquareRoot
    {
        public static void main( String[] args) 
        {
        Scanner keyboard = new Scanner(System.in);
        double a, b;
        
        System.out.println( "Square Root! ");
        System.out.print( "Enter a number: " );
        
        do {
        a = keyboard.nextDouble();
        if ( a >= 0 ){
            b = Math.sqrt(a);
            System.out.println( b );
        }
        else if ( a < 0 ){
            System.out.println(" You can't take the square root of a negative number stupid " );
            System.out.print( "Try again: " );
        }
        } while ( a < 0 );
        
        }
    }
                    
                
        
    

Picture of the output

Assignment 74