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) {

    // Swap b and c if out of order
    if (b > c) {
      // we declare local variables as close as possible to their
      // first use, to improve readability
      int temp = b;
      b = c;
      c = temp;
    }
    // the variable temp is not visible here, because its scope is
    // limited to the if block inside which it was declared.
    
    assert b <= c;
    if (a <= b) {
      assert a <= b && b <= c;
      return b;
    }
    assert a > b && c > b;
    return Math.min(a, c);
  }
}
