NLKappa

chto 2

Oct 12th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.23 KB | None | 0 0
  1.     import java.util.Scanner;
  2.  
  3.     import static java.lang.StrictMath.sqrt;
  4.  
  5.     public class Main {
  6.         public static boolean RectCircle (int a, int b, int rad) {
  7.             if (Math.hypot(a,b) <= rad*2) { //Math.hypot - вычисление гипотенузы из двух данных катетов
  8.                 return true;
  9.             } else {
  10.                 return false;
  11.             }
  12.         }
  13.  
  14.         public static void main(String[] args) {
  15.             Scanner sc = new Scanner(System.in);
  16.             System.out.println("Введите радиус окружности: ");
  17.             int rad = sc.nextInt();
  18.             System.out.println("Введите первую сторону прямоугольника: ");
  19.             int a = sc.nextInt();
  20.             System.out.println("Введите вторую сторону прямоугольника: ");
  21.             int b = sc.nextInt();
  22.             if (RectCircle(a,b,rad)) {
  23.                 System.out.println("Прямоугольник войдет в окружность.");
  24.             } else {
  25.                 System.out.println("Прямоугольник не войдет в окружность.");
  26.             }
  27.  
  28.         }
  29.     }
Advertisement
Add Comment
Please, Sign In to add comment