private int inRange(int number,int min,int max){
  int result;
  result=Math.min(number,max);
  result=Math.max(result,min);
  return result;
}

private int inRange ( int number , int min , int max ) { int result ; result = Math . min ( number , max ) ; result = Math . max ( result , min ) ; return result ; }
if given number is in given range - [ min , max ] - the number is returned unchanged , otherwise - the closest number in range is returned : min or max
