初学者java小程序,求java大神帮我补充一下空缺代码!
2017-12-13 · 百度知道合伙人官方认证企业
代码如下:
public class Test {
public static void main(String[] args) throws IOException {
int num;
InputStreamReader in = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(in);
System.out.println("请输入一个整数:");
String s = br.readLine();
num = Integer.parseInt(s);
System.out.println();
System.out.println("输入的整数是:" + num);
if (num % 3 == 0) {
if (num % 5 == 0) {
System.out.println(num + "能同时被3、5整除");
} else {
System.out.println(num + "能被3整除,但是不能被5整除");
}
} else {
if (num % 5 == 0) {
System.out.println(num + "能被5整除,但是不能被3整除");
} else {
System.out.println(num + "不能被3、5整除");
}
}
}
}
验证: