作业三
2016-03-28 22:58
148 查看
import java.util.Scanner;
public class TestScanner {
/**
* @param args
*/
public static void main(String[] args){
//TOOD Auto-generated method stub
/*int nextValue;
Scanner kpInput = new Scanner(System.in);
nextValue = kpInput.nextInt();
System.out.println("读取:" + nextValue);
kpInput.close();
从键盘读取若干整数并读取输出*/
int nextValue, sum = 0;
Scanner kpInput = new Scanner(System.in);
while(kpInput.hasNextInt()){
nextValue = kpInput.nextInt();
sum += nextValue;
System.out.println(nextValue);
}
kpInput.close();
System.out.println("Sum: " + sum);
}
}
public class TestScanner {
/**
* @param args
*/
public static void main(String[] args){
//TOOD Auto-generated method stub
/*int nextValue;
Scanner kpInput = new Scanner(System.in);
nextValue = kpInput.nextInt();
System.out.println("读取:" + nextValue);
kpInput.close();
从键盘读取若干整数并读取输出*/
int nextValue, sum = 0;
Scanner kpInput = new Scanner(System.in);
while(kpInput.hasNextInt()){
nextValue = kpInput.nextInt();
sum += nextValue;
System.out.println(nextValue);
}
kpInput.close();
System.out.println("Sum: " + sum);
}
}
相关文章推荐
- Wireshark-ARP数据包
- Interface中定义方法
- C语言基础练习篇(1)
- POJ 3187(Backward Digit Sums 穷竭搜索,杨辉三角性质)
- 汉字转换拼音
- Android:gravity和Android:layout_gravity的区别
- 添加FB登陆时,需要curl扩展
- 算法训练 排列问题
- Spring JDBC学习笔记(1):查询数据库数据之JdbcTemplate的使用
- Android常见的泄露以及解决策略
- POJ 2418 简单trie树
- POJ 2418 简单trie树
- HDU 2795 线段树第三发!
- docker(2)
- Spring 依赖注入 @Autowired @Inject
- 单元测试:复利计算
- MyBatis学习总结(一)——MyBatis快速入门
- leetcode_082 Remove Duplicates from Sorted List
- c#观察者模式
- flash跨域策略文件crossdomain.xml配置详解