Assignemnt #74: Adding

Code

    /// Name: Kelsey Lieberman
    /// Period 5
    /// Program Name: AddingValuesLoop
    /// File Name: AddingValuesLoop.java
    /// Date Finished: 12/14/2015
    
import java.util.Scanner;

public class SafeSquareRoot
{
    public static void main(String[] args)
    {
        Scanner keyboard = new Scanner(System.in);
        
        double num;
            
        System.out.println("SQuArE ROoT!!!!!");
        
        do
        {
            System.out.print("Enter a number: ");
            num = keyboard.nextDouble();
            
            if (num >= 0)
                System.out.println("The square root of " + num + " is " + Math.sqrt(num) + ".");
            else if (num < 0)
                System.out.println("You can't take the square doot of a negative, m'lady");
        } while (num < 0);
    }
}
    

Picture of the output

Assignment 74