This code in C will read integers until you type Control-Z (end of entry in windows).
void main(int argc, char *argv[]) {
char line[100];
int sum = 0;
while(scanf("%s", line) == 1) {
sum += atoi(line);
}
printf("%d\n", sum);
}
How do I do the same using Scanner
in Java?