Java-第三章-從鍵盤輸入整數判斷是3和5的倍數!

import java.util.*;
public class lianxi72_4 {
	public  static void main (String [] args){
		Scanner inport =new Scanner(System.in);
		System.out.println("請輸入一個整數");
		int math =inport.nextInt();
		if (math % 3 == 0 && math % 5== 0)
		{
			System.out.println("該數是3或5倍數");
		}else if (math %3==0)
		{
			System.out.println("該數是3倍數");
		}else if (math %5==0)
		{
			System.out.println("該數是5倍數");
		}else
		{
			System.out.println("該數不能被3和5中的任何一個數整除");
		}
	}
}


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章