キーボードから読み込んだ三つの整数値の中央値を求めて表示するプログラムです。

import java.util.Scanner;

class ex0313 {

public static void main(String[] args) {
Scanner stdIn = new Scanner(System.in);

System.out.print("整数a:"); int a = stdIn.nextInt();
System.out.print("整数b:"); int b = stdIn.nextInt();
System.out.print("整数c:"); int c = stdIn.nextInt();

int mid = a;
if (a > b) {
if (b > c)
mid = b;
else if (c < a)
mid = c;
} else {
if (a > c)
mid = a;
else if (c > b)
mid = b;
else
mid = c;
}

System.out.println("中央値は" + mid + "です。");
}
}