Assignment #74
Code
///jack newsom
///period 5
///program sqrt
///filename sqrt.java
///date completed 10/13/15
import java.util.Scanner;
public class sqrt
{
public static void main( String[] args )
{
Scanner bot = new Scanner(System.in);
System.out.println("This is a square-root calculator.");
System.out.println("Enter a number for me to take the square root of!");
int number = bot.nextInt();
while ( number <= 0 )
{
System.out.println("You can't take the square root of a negative number.");
System.out.println("Try again: ");
number = bot.nextInt();
}
double sqrt = Math.sqrt(number);
System.out.println("The square root of " + number + " is " + sqrt + ".");
}
}
Picture of the output