단순 if문 두번을 사용해서 숫자가 홀수인지 짝수인지 구분하여 출력하세요.
package com.dream.controls;
public class ControlEx02 {
public static void main(String[] args) {
int num = 9;
String str = "";
/*
if(num % 2 == 0) str = "짝수";
if(num % 2 == 1) str = "홀수";
*/
//양자 택일의 상황에서 사용
if(num % 2 == 0) str = "짝수";
else str = "홀수";
System.out.println(num+"은 "+str+"이다.");
}
}