Java-第三章-从键盘输入整数判断是3和5的倍数!
时间:2014-06-10 23:47:49
收藏:0
阅读:265
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中的任何一个数整除");
}
}
}
评论(0)