74 Safe Square Root
Code
///Name: Joshua Bautista
///Period: 6
///Project Name: SafeSquareRoot
///File Name: SafeSquareRoot.java
///Date: 2/26/2015
import java.util.Scanner;
public class SafeSquareRoot
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
int number;
Double root;
System.out.println(" Square Root! ");
System.out.print(" Enter a number : ");
number = keyboard.nextInt();
while( number <= 0 )
{
System.out.println(" You can't take the square root of a negative number, silly ");
System.out.println(" Please try again: ");
number = keyboard.nextInt();
}
root = Math.sqrt(number);
System.out.println(" The square root of " + number + " is " + root + " . ");
}
}
Picture of the output