public class Middle {
  /**
   * Return the value that would be in the middle
   * if a, b, and c were sorted.
   */
  public static int middle(int a, int b, int c) {
    int temp;

    // If b and c are out of order, swap them.
    if (b > c) {
      temp= b;
      b= c;
      c= temp;
    }

    // Now, we know b <= c.
    if (a <= b) {
      // Here, a <= b <= c.
      return b;
    }

    // Otherwise, a and c are both greater than b.
    // The smaller of the two is in the middle.
    return Math.min(a, c);
  }
}
