[Solved] how to check the range using only if statement


if you want to check the difference between two numbers, you need to subtract them. The result may be negative if the first number is smaller than the second, so you may want to use Math.abs() which will make it positive again. Then you have a positive number that you can check for being between 1 and 3:

int difference = Math.abs(frontL - frontR);

if (difference >= 1 && difference <= 3) {
    inflation = "good";
}
else {
    warning = "Warning: difference between pressure left and right detected";
    inflation = "BAD";
}

solved how to check the range using only if statement