/** * Title: Chapter 3, "Control Statements" * Description: Chapter 3 Examples * Copyright: Copyright (c) 2000 * Company: Armstrong Atlantic State University * @author Y. Daniel Liang * @version 1.0 */ // TestWhile.java: Test the while loop public class TestWhile { /**Main method*/ public static void main(String[] args) { int data; int sum = 0; // Read an initial data System.out.println("Enter an int value"); data = MyInput.readInt(); // Keep reading data until the input is 0 while (data != 0) { sum += data; System.out.println( "Enter an int value, the program exits if the input is 0"); data = MyInput.readInt(); } System.out.println("The sum is " + sum); } }