import java.util.Scanner;

/**********************************************************************
// Note: the acknowledgement section is not needed for labs
// Acknowledgements: ...
/**********************************************************************

/**********************************************************************
 * Class purpose: This class demonstrates the indefinite loop.
 *                Terminal value used to control loop operation.
 * 
 * @author  Nancy Harris
 * @version 10/20/06
 *********************************************************************/

public class LoopWhile
{
   /******************************************************************
    * Function purpose: Main will be used to demonstrate loops 
    *
    * @param args Command line arguments, ignored
    *****************************************************************/
   public static void main(String [] args)
   {
		Scanner stdin;
		int	 sum;
		int	 inputVal;
		
		stdin = new Scanner(System.in);
		System.out.printf ("Input numbers (negative number to end): ");
		sum = 0;

		inputVal = stdin.nextInt();
		while (inputVal >= 0)
		{
			sum = sum + inputVal;
			inputVal = stdin.nextInt();
		}

		System.out.printf("Sum is %d\n", sum);
	}
}
