1 Star 0 Fork 0

schwarizard / chapter 8

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
Average3 652 Bytes
一键复制 编辑 原始数据 按行查看 历史
schwarizard 提交于 2016-03-29 23:02 . new file
import java.util.*;
public class Average3 {
public static void main(String[] args) {
Scanner console = new Scanner(System.in);
double sum = 0;
int count = 0;
while (true) {
try {
int number = console.nextInt();
if (number == 0) {
break;
}
sum += number;
count++;
}catch (InputMismatchException ex) {
System.out.printf("略过非整数输入:%s%n",console.next());
}
}
System.out.printf("平均 %.2f%n", sum / count);
}
}
Java
1
https://gitee.com/schwarizard/chapter-8.git
git@gitee.com:schwarizard/chapter-8.git
schwarizard
chapter-8
chapter 8
master

搜索帮助