Assignment #74 Safe Square Root
Code
///Name: Ian Grant
///Period:5
///Project Name: Safe Square Root
///File Name:SafeSqurRt.java
///12/07/15
import java.util.Scanner;
public class SafeSqurRt
{
public static void main(String[] args)
{
int num;
Scanner stuff=new Scanner(System.in);
System.out.println("SQUARE ROOT!");
do
{
System.out.print("Enter a number: ");
num=stuff.nextInt();
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 root of a negative number, silly.");
} while(num< 0);
}
}
Output