Assignemnt #74 Safe Square Root
Code
///Name: Prooz Fereydouni
///Period: 7
///Project Name: Safe Square Root
///File Name: SSR.java
///Date: 1/26/2016
import java.util.Scanner;
public class SSR
{
public static void main(String[] args)
{
Scanner keyboard = new Scanner(System.in);
int in=0;
System.out.println("Enter a positive number.");
in = keyboard.nextInt();
while(in<0)
{
System.out.println("Wrong input. Your number can't be negative.");
in = keyboard.nextInt();
}
System.out.println("The square root of the number is: " + Math.sqrt(in));
}
}
Picture of the output