返回列表 發帖
import java.util.Scanner;


public class JPA01 {
          static Scanner o= new Scanner(System.in);
        public static void main(String[] args) {
                // TODO 自動產生的方法 Stub
               
                test();
                test();
                test();
                test();
               
                       
                }
               
          
        private static void test() {
                // TODO 自動產生的方法 Stub
               
                 System.out.print("Enter an integer:");
                 int u=o.nextInt();
                if( u%2==0 && u%3==0 )
                {
                        System.out.println( u+"是2、3、6的倍數");
                       
                }
                if( u%2!=0 && u%3==0 )
                {
                        System.out.println( u+"是3的倍數");
                       
                }
                if( u%2==0 && u%3!=0 )
                {
                        System.out.println( u+"是2的倍數");
                       
                }
                else if(u%2!=0 && u%3!=0)
                {
                        System.out.println(u+"不是2、3、6的倍數");
                       
                }
        }
       

}

TOP

返回列表