프로그래밍(programming)

[백준 문제 1000]_자바 A+B

정보나눔중 2020. 11. 17. 21:55
반응형

단계별로 풀어보기

 

1단계: 입출력과 사칙연산

- 5단계 : 두수를 입력받고 합을 출력하는 문제

 

 

 

문제 풀이:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import java.util.*;
 
public class Main {
    
    public static void main(String[] args){
        
        Scanner scan = new Scanner(System.in);
        
        int a = scan.nextInt();
        int b = scan.nextInt();
       
        while(a<0 || a>10 || b<0 || b>10){
            System.out.println("a,b 두수를 0~10 사이로 입력하세요.");
            a = scan.nextInt();
            b = scan.nextInt();
        }
        
        System.out.println(a+b);
        
    }    
}
cs

 

반응형