Guest User

Untitled

a guest
Oct 23rd, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class squareRoot {
  4. public static void main(String[] args) {
  5. Scanner input = new Scanner(System.in);
  6. System.out.print("Enter your input: ");
  7. int n = input.nextInt();
  8.  
  9. if (n < 0) {
  10. System.out.println("It's impossible to get square root of a negative number");
  11. return;
  12. }
  13.  
  14. double output = Math.sqrt(n);
  15. System.out.print(output);
  16. }
  17. }
Add Comment
Please, Sign In to add comment