码迷,mamicode.com
首页 > 其他好文 > 详细

作业三

时间:2016-03-28 23:16:47      阅读:240      评论:0      收藏:0      [点我收藏+]

标签:

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);
}

}

技术分享 

作业三

标签:

原文地址:http://www.cnblogs.com/my843532194/p/5331100.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!