// 2.輸入一個數字判斷他是奇數還是偶數
public static void Test2() {
Scanner input = new Scanner(System.in);
System.out.println("請輸入一個整數:");
try {
int zhengshu = input.nextInt();
if (zhengshu % 2 == 0) {
System.out.println("您輸入的" + zhengshu + "是一個偶數!");
} else {
System.out.println("您輸入的" + zhengshu + "是一個奇數!");
}
} catch (Exception e) {
System.out.println("您的輸入有誤!");
Test2();
}
}