line is a String object that holds an unknown number of int values separated by spaces. Write a segment of code that will compute and display the sum of the values in line.

What will be an ideal response?


```
int sum = 0;
int val; // the next value from line
Scanner s = new Scanner(line);
while (s.hasNext()) {
val = s.nextInt();
sum += val;
}
System.out.println("The sum is " + sum);
```

Computer Science & Information Technology

You might also like to view...

What is the name of the special Alice object that allows you to add text to a world?

a. 3D text b. Super text c. Big text d. String text e. None of these

Computer Science & Information Technology

Once buttons are added to the navigation form, the captions, or text, can be changed or replaced with ________ instead of the button caption to further customize the form

Fill in the blank(s) with correct word

Computer Science & Information Technology

The file extension used for a chart template is ________

A) .xml B) .xlsx C) .xltx D) .crtx

Computer Science & Information Technology

________ failure often goes undetected for extended periods of time

Fill in the blank(s) with correct word

Computer Science & Information Technology