用scanner從鍵盤輸入3個整數,輸出最大的值.
public class Max {
public static void main(String[] args) {
System.out.println("請輸入三個整數:");
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
if (a > b) {
if (a > c) {
System.out.println("最大的一個數是:" + a);
} else {
System.out.println("最大的一個數是:" + c);
}
} else {
if (b > c) {
System.out.println("最大的一個數是:" + b);
} else {
System.out.println("最大的一個數是:" + c);
}
}
}
}