Assignemnt #74 and Safe Square Root
Code
/// Name: Brian Phillips
/// Period: 5
/// Program name: SafeSqrt.java
/// File Name: Safe Square Root
/// Date Finished: 2/22/2016
import java.util.Scanner;
public class safesqrt
{
public static void main(String[] args)
{
int Number;
Scanner keyboard = new Scanner(System.in);
System.out.println("SQUARE ROOT!");
do
{
System.out.print("Enter a number: ");
Number = keyboard.nextInt();
if (Number > 0)
System.out.println("The square root of " + Number + " is " + Math.sqrt(Number));
else if (Number < 0)
System.out.println("Don't put a negative number here ever again or I will hunt you down.");
} while(Number < 0);
}
}
Picture of the output