프로그래밍(programming)
[백준 문제 10869]_자바 사칙연산
정보나눔중
2020. 11. 29. 00:55
반응형
단계별로 풀어보기
1단계 : 입출력과 사칙연산
-9단계 : 두 자연수 A와 B가 주어진다. 이때, A+B, A-B, A*B, A/B(몫), A%B(나머지)를 출력
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
import java.util.*;
class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int A = sc.nextInt();
int B = sc.nextInt();
while(A<1 || A>10000 || B<1 || B>10000){
System.out.println("A,B를 1~ 10,000 사이의 수로 입력하세요.");
A = sc.nextInt();
B = sc.nextInt();
}
System.out.println(A+B);
System.out.println(A-B);
System.out.println(A*B);
System.out.println(A/B);
System.out.println(A%B);
}
}
|
cs |
반응형