Advertisement
kocev

SqrtProblem

Feb 18th, 2020
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.51 KB | None | 0 0
  1. import java.util.InputMismatchException;
  2. import java.util.Scanner;
  3.  
  4. public class Sqrt {
  5.     public static void main(String[] args) {
  6.         try {
  7.             Scanner scanner = new Scanner(System.in);
  8.             int number = scanner.nextInt();
  9.             double numberSqrt = Math.sqrt(number);
  10.             System.out.printf("%.5f", numberSqrt);
  11.         }
  12.         catch (InputMismatchException e){
  13.             System.out.println("Wrong input! Please next time enter number but not symbol.");
  14.         }
  15.     }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement