I'm practicing logic operators, but I don't know the answer ㅜ.ㅜ..

Asked 2 years ago, Updated 2 years ago, 102 views

public class LogicalOperatorExam{ public boolean isAgeDiscountable(int age){ boolean isDiscount = false; //Please correct the line below here. if( ________ ) { isDiscount = true; } else{ isDiscount = false; }

return isDiscount;// This is the code for the result test.
}

//Below is code for execution. Don't edit it.
public static void main(String[]args){
    LogicalOperatorExam exam = new LogicalOperatorExam();
    exam.isAgeDiscountable(15);
    exam.isAgeDiscountable(27);
}

}

logical-operations

2022-09-21 15:57

1 Answers

If you check whether you are under 19 or over 60, there are two conditions.

You don't have to satisfy both of these conditions, but even if you satisfy only one, you get a discount? So you can use ||(or operation).

age<=19 || 60<=age


2022-09-21 15:57

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.