Network disconnection
Description
어떤 사람이 할인 대상인지 검사하려고 합니다. 나이가 19 이하거나 60 이상이라면 할인 대상입니다.
int형 변수 age가 19 이하거나 60 이상이라면 isDiscount
에 true
를, 아니라면 isDiscount
에 false
를 저장하게 빈칸을 채워보세요.
힌트1
논리 연산을 표로 나타내면 다음과 같습니다.
A | B | A && B | A || B | !A |
---|---|---|---|---|
TRUE | TRUE | TRUE | TRUE | FALSE |
TRUE | FALSE | FALSE | TRUE | FALSE |
FALSE | TRUE | FALSE | TRUE | TRUE |
FALSE | FALSE | FALSE | FALSE | TRUE |
-
age가 19 이하거나 60 이상이면 할인 대상입니다. 두 조건 중 하나만 만족해도 되므로, '||'을 이용합니다.
age <= 19 || age >= 60
를 입력한 후, 코드를 제출해보세요. ↩
Fill type challenge HOWTO
- In the Fill type challenge, you have to fill the blank with appropriate code
- The given code except the blank cannot be edited.
- An error message will be shown in the Result area when you leave the blank empty.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
public class LogicalOperatorExam {
public boolean isAgeDiscountable(int age) {
boolean isDiscount = false;
// 아래 빈칸을 채워 코드를 완성하세요.
if( ) {
isDiscount = true;
}
else {
isDiscount = false;
}
return isDiscount;
}
public static void main(String[]args) {
LogicalOperatorExam exam = new LogicalOperatorExam();
exam.isAgeDiscountable(15);
exam.isAgeDiscountable(27);
}
}
Result
Stop
Result of [Run] or [Submit] will be displayed here