
package Chapter03;
import java.util.Scanner;
public class exercise31 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("첫 번째 숫자를 입력하세요: ");
int n1 = scanner.nextInt();
System.out.print("두 번째 숫자를 입력하세요: ");
int n2 = scanner.nextInt();
int Big = ((n1 + n2) + Math.abs(n1 - n2)) / 2;
int Small = ((n1 + n2) - Math.abs(n1 - n2)) / 2;
int num1 = Big / Small;
int num2 = Big % Small;
System.out.println("큰 수를 작은 수로 나눈 몫은 " + num1 + "이고, 나머지는 " + num2 + "이다.");
}
}
'Java > 과제' 카테고리의 다른 글
chapter03) 연산자 example - 입력 연도가 윤년인지 확인하는 프로그램 (0) | 2022.08.07 |
---|---|
chapter03) 연산자 example - 2가지 조건 중 하나를 만족할 때 문구가 나타나는 프로그램 (0) | 2022.08.07 |
chapter02) 변수와 타입 example - 저금통 안에 총 얼마가 들어있는지 출력하는 프로그램 (0) | 2022.08.07 |
chapter02) 변수와 타입 example - 원기둥의 밑변의 넓이와 부피를 계산하는 프로그램 (0) | 2022.08.07 |
chapter02) 변수와 타입 example - 빛의 속도로 도착하는 데 걸리는 시간 (0) | 2022.08.07 |