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
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
© 2024 OneMinuteCode. All rights reserved.