import java.util.Scanner;
public class ex10 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
System.out.print("첫번째 원의 중심과 반지름 입력>>");
int centerX1 = sc.nextInt();
int centerY1 = sc.nextInt();
int radius1 = sc.nextInt();
System.out.print("두번째 원의 중심과 반지름 입력>>");
int centerX2 = sc.nextInt();
int centerY2 = sc.nextInt();
int radius2 = sc.nextInt();
double result = (centerX1 - centerX2)*(centerX1 - centerX2)+(centerY1 - centerY2)*(centerY1 - centerY2);
if(Math.sqrt(result)<=radius1+radius2) {
System.out.println("두 원은 서로 겹친다.");
}
else {
System.out.println("두 원은 서로 겹치지않는다.");
}
sc.close();
}
}
결과
첫번째 원의 중심과 반지름 입력>>10 10 3
두번째 원의 중심과 반지름 입력>>12 12 2
두 원은 서로 겹친다.'명품JAVA프로그래밍 > 2장 자바 기본 프로그래밍' 카테고리의 다른 글
| [명품JAVA프로그래밍] 2장 실습문제 12번 (0) | 2021.12.16 |
|---|---|
| [명품JAVA프로그래밍] 2장 실습문제 11번 (0) | 2021.12.16 |
| [명품JAVA프로그래밍] 2장 실습문제 9번 (0) | 2021.12.16 |
| [명품JAVA프로그래밍] 2장 실습문제 8번 (0) | 2021.12.15 |
| [명품JAVA프로그래밍] 2장 실습문제 7번 (0) | 2021.12.15 |