Assignemnt #74 Square
Code
/// Name: Caelan Dorstad
/// Period: 6
/// Program Name: sqr
/// File Name: sqr.java
/// Date Finished: 2/19/2016
import java.util.Scanner;
import java.util.InputMismatchException;
public class sqr{
public static void main(String[] args){
Scanner keyboard = new Scanner(System.in);
int n;
System.out.println("YO");
System.out.print("#: ");
n = keyboard.nextInt();
while (n < 0){
System.out.println("You can't take the square root of a neg num.");
System.out.print("#: ");
n = keyboard.nextInt();
}
double sqr = Math.sqrt(n);
System.out.println("sqr of "+n+" is: "+sqr);
}
}
Picture of the output