본문 바로가기
Algorithm/Programmers

[Programmers] Lv.0 / 홀짝 구분하기 / Java

by unknownomad 2023. 10. 17.

문제

 

풀이

import java.util.Scanner;

public class Solution {
    public static void main(String[] args) {
    
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        
        if(n % 2 == 0) {
            System.out.println(n + " is even");
        } else {
            System.out.println(n + " is odd");
        }
        sc.close();
    }
}

 

출처

https://school.programmers.co.kr/learn/courses/30/lessons/181944

댓글