import java.util.Scanner; public class ThreeIntCompare { public static void main(String[] args) { // 輸入並讀取三個整數 Scanner scn = new Scanner(System.in); System.out.println("Enter the first integer:"); int num1 = scn.nextInt(); System.out.println("Enter the second integer:"); int num2 = scn.nextInt(); System.out.println("Enter the third integer:"); int num3 = scn.nextInt(); // 找max int max = num1; if(num2>max) { max = num2; }if(num3>max) { max = num3; } // 找 min int min = num1; if(num2<min) { min = num2; }if(num3<min) { min = num3; } // 輸出結果 System.out.println("Maximum: "+max); System.out.println("Minimum: "+min); scn.close(); } }