Code
/// Name: Afaf Nabeeha
/// Period: 7
/// Program Name: Safe Square Root
/// File Name: Square.java
/// Date Finished: 12/20/2015 public class Square
import java.util.Scanner;
public class Square
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
double user, answer;
System.out.println( "SQUARE ROOT!" );
System.out.print( "Enter a number: " );
user = keyboard.nextDouble();
answer = 0;
while ( user > 0 )
{
answer = Math.sqrt(user);
System.out.println( "The square root of " + user + " is " + answer );
System.out.print( "Enter a number: " );
user = keyboard.nextDouble();
}
System.out.println( "Error, invalid input. " );
}
}
Picture of the output