本帖最後由 巫沛庭 於 2018-6-19 19:37 編輯
- import java.util.*;
- public class JPA02 {
- static Scanner input = new Scanner(System.in);
- public static void main(String[] args) {
- test();
- test();
- test();
- test();
- }
-
- static void test() {
- System.out.println("Enter an integer : ");
- int x=input.nextInt();
- if(x%2==0 && x%3==0)
- {
-
-
- System.out.println(x+"是2,3,6的倍數");
-
-
-
- }
- else if(x%2==0)
- {
- System.out.println(x+"是2的倍數");
- }
- else if(x%3==0)
- {
- System.out.println(x+"是3的倍數");
-
- }
- else{
- System.out.println(x+"不是2,3,6的倍數");
- }
- }
- }
複製代碼 |