문제 2 int형 변수 age의 값을 검사해 age가 20대인지 검사하려고 합니다. 5행의 빈칸을 수정해 20대라면 isTwenties에 true를, 그렇지 않으면 false를 저장하도록 만들어보세요.
public class LogicalOperatorExam{
public boolean isAgeTwenties(int age) {
boolean isTwenties = false;
// 이 아랫줄을 수정하세요.
if( _____________________ ) {
isTwenties = true;
}else{
isTwenties = false;
}
return isTwenties; // 결과 테스트를 위한 코드입니다.
}
// 아래는 실행을 위한 코드입니다. 수정하지 마세요.
public static void main(String[] args) {
LogicalOperatorExam exam = new LogicalOperatorExam();
System.out.println(exam.isAgeTwenties(19));
System.out.println(exam.isAgeTwenties(25));
System.out.println(exam.isAgeTwenties(30));
}
}
실행결과
false true false