Assignment 74
import java.util.Scanner;
public class SquareRoot
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
System.out.println("This program will find the square root of a number.");
System.out.print("Your number: ");
double given = keyboard.nextDouble();
while (given < 0)
{
System.out.println("Input must be a positive number");
System.out.print("Your number: ");
given = keyboard.nextDouble();
}
double root = Math.sqrt(given);
System.out.println("The square root of " +given+ " is " +root+ ".");
}
}