Assignemnt #74 and sqr
Code
///Name: Luke Shin
///Period: 7
///Project Name: sqr
///File Name: sqr.java
///Date: 01/04/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