作业三

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

}

 

posted @ 2016-03-28 22:58  牧云丶枫月  阅读(104)  评论(0编辑  收藏  举报