public class Middle {
  /** Returns the value that, if a, b, and c were sorted,
    * would be in the middle. */
  public static int middle(int a, int b, int c) {
    
    int temp;
    
    // Swap b and c if out of order
    if (b > c) {
      temp = b;
      b = c;
      c = temp;
    }
    
    // b <= c
    if (a <= b) {
      // a <= b <= c
      return b;
    }
    // a and c are both greater than b
    return Math.min(a, c);
  }
}
