返回列表 發帖
本帖最後由 巫沛庭 於 2018-6-19 19:37 編輯
  1. import java.util.*;
  2. public class JPA02 {
  3.     static Scanner input = new Scanner(System.in);
  4.     public static void main(String[] args) {
  5.         test();
  6.         test();
  7.         test();
  8.         test();
  9.     }
  10.    
  11.     static void test() {
  12.         System.out.println("Enter an integer : ");
  13.         int x=input.nextInt();
  14.         if(x%2==0 && x%3==0)
  15.         {
  16.      
  17.          
  18.                 System.out.println(x+"是2,3,6的倍數");
  19.                
  20.          
  21.          
  22.         }
  23.         else if(x%2==0)
  24.         {
  25.                   System.out.println(x+"是2的倍數");
  26.         }
  27.         else if(x%3==0)
  28.         {
  29.               System.out.println(x+"是3的倍數");
  30.              
  31.         }
  32.         else{
  33.                 System.out.println(x+"不是2,3,6的倍數");
  34.         }
  35.     }
  36. }
複製代碼

TOP

返回列表