Search

변수3_개념02_짝수홀수

대분류
STEP01 변수
소분류
변수3_개념

영상

개념

package 변수3_개념; /* # 비교 연산자를 활용해 짝수, 홀수 판별법 짝수 : 2의 배수이면 짝수 홀수 : 2의 배수가 아니면 홀수 2의 배수 : 어떤 수를 2로 나눴을 때 나머지가 0이면 2의 배수 3의 배수 : 어떤 수를 3으로 나눴을 때 나머지가 0이면 3의 배수 */ public class 변수3_개념02_짝수홀수 { public static void main(String[] args) { int a = 10; int b = 11; System.out.println("짝수 : " + (a % 2 == 0)); System.out.println("짝수 : " + (b % 2 == 0)); System.out.println("---------------------"); System.out.println("홀수 : " + (a % 2 != 0)); System.out.println("홀수 : " + (b % 2 != 0)); } }
Java
복사