美文网首页
聪聪工作室---JAVA入门小程序---输入一个整数,判断能否被

聪聪工作室---JAVA入门小程序---输入一个整数,判断能否被

作者: 繁花流水congcong | 来源:发表于2016-07-12 15:55 被阅读334次

package congcong;

import java.util.Scanner;

public class or35{

public static void main(String[] args) {

Scanner sc=new Scanner(System.in);

int num=sc.nextInt();

boolean str=or35(num);

System.out.println(str);

}

private static boolean or35(int num) {

// TODO Auto-generated method stub

if((num%3==0)||(num%5==0)){

System.out.println("能被3和5整除");

return true;

}else{

return false;

}

}

}

相关文章

网友评论

      本文标题:聪聪工作室---JAVA入门小程序---输入一个整数,判断能否被

      本文链接:https://www.haomeiwen.com/subject/elqsjttx.html