import java.util.Scanner;
public class TestDoWhile {
/** Main method */
public static void main(String[] args) {
int data;
int sum = 0;
// Create a Scanner
Scanner input = new Scanner(System.in);
// Keep reading data until the input is 0
do {
// Read the next data
System.out.print(
"Enter an integer (the input ends if it is 0): ");
data = input.nextInt();
sum += data;
} while (FILL_CODE_OR_CLICK_ANSWER);
System.out.println("The sum is " + sum);
}
} // LiveExample is used exclusively throughout the LIANG Revel books |