본문 바로가기
프로그래밍/JAVA

[예제]홀수짝수 구별하기

by Edgemine 2017. 4. 29.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
public static void main(String arg[])
   {
       int num1;
      
       Scanner s = new Scanner(System.in);
       System.out.println("숫자?");
       num1 = s.nextInt();
       num1 = num1%2;
       if(num1 == 0)
       {
           System.out.println("짝수");
       }
       else
       {
           System.out.println("홀수");
       }
       //종료
       s.close();
   }
}
cs

이 소스는 홀수 짝수를 구별하는 소스입니다^^