Assignemnt #74 and Safe square root
Code
///name: Ben Borglin
///period: 6
///Program name: Safe Square Root
///file name: SSRoot.java
///Date finished: 10/27/15
import java.util.Scanner;
public class SSRoot
{
public static void main( String[] args)
{
Scanner keyboard = new Scanner(System.in);
double n;
System.out.println("Say a number and I will find the square root of it.");
do
{
System.out.print("Enter your number: ");
n = keyboard.nextInt();
double sroot = Math.sqrt(n);
System.out.println( sroot );
} while (n > 0);
System.out.println("Sorry it has to be a positive number to work.");
}
}
Picture of the output