比这篇新的文章: Textarea的自动缩进以及Tab缩进支持
比这篇旧的文章: 求积分 f(z) = \int_0^1 {(1-h*h)/sqrt(1-2*h*z+h*h)} dh

实验一 Java集成开发环境设置与使用

语言: Java, 标签: 无  2008/10/18发布 1年前更新
作者: lintix, 点击659次, 评论(0), 收藏者(0), , 打分:

背景
主题: 字体:
01 import java.io.*;
02
03 public class countThreeFive {
04    
05     public static void main(String[] args) throws IOException {
06         BufferedReader bufRead =  new BufferedReader(new InputStreamReader(System.in));
07         String inputNum;
08         int intNum;
09
10         System.out.println("请输入一个整数:(输入exit可以结束程序)");
11
12         while(true) {
13             inputNum = bufRead.readLine();
14             if(inputNum.equals("exit")) break;
15             intNum = Integer.parseInt(inputNum);
16
17             if(countThree(intNum) == 1) System.out.println(intNum + "能被3整除!");
18                 else System.out.println(intNum + "不能被3整除!");
19
20             if(countFive(intNum) == 1) System.out.println(intNum + "能被5整除!");
21                 else System.out.println(intNum + "不能被5整除!");
22         }
23     }
24
25     static int countThree(int three) {
26         if(three % 3 == 0) return 1;
27             else return 0;
28    
29     }
30
31     static int countFive(int three) {
32         if(three % 5 == 0) return 1;
33             else return 0;
34    
35     }
36 }


所有评论,共0条:( 我也来说两句)


发表评论

注册登录后再发表评论