how to use greater than and less than in a single if statement in java

后端 未结 2 831
庸人自扰
庸人自扰 2021-01-22 17:04

I have made a BMI calculator from programming by doing, one of the thing i have to do is add categories using if statements. 18.5 to 24.9 normal weight so that would be one of t

2条回答
  •  有刺的猬
    2021-01-22 18:08

    You could write your own method to check if between,

    public static boolean isBetween(int low, int high, int vmi) {
        return high > low ? bmi > low && bmi < high : bmi > high && bmi < low;
    }
    

提交回复
热议问题