/*******************************************************************************
Author:                         Rebecca Hasti, hasti@cs.wisc.edu
                                        copyright 2000, all rights reserved
Compiler:                       Metrowerks CodeWarrior (JDK 1.2)
Platform:                       Windows NT 4.0 (or Windows 95)
*******************************************************************************/

import java.io.*;

/**
 * This program computes the sum of any number of integers given by the user.
 * It repeatedly prompts the user for the next number until the user enters 'q'.
 * The program then reports the sum of the numbers.
 *
 * Bugs: The program assumes that each time the user is prompted, the user
 *       enters either an integer or 'q' (or 'Q').  That is, no error-checking
 *       of the user's input is done.
 **/
public class ConsoleSum {

	public static void main(String args[]) throws IOException {
	
		boolean again = true;
		int sum = 0;
		
		BufferedReader stdin = new BufferedReader(
		                           new InputStreamReader(System.in));
		
		while (again) {
		
        	System.out.print("Enter an integer: ");
        	String s = stdin.readLine();
        	char c = s.charAt(0);
        	
       		if (c == 'q' || c == 'Q')
        		again = false;
        			
        	else 
        		sum += Integer.parseInt(s);
        			
        } // end while
        
        System.out.println("The sum is " + sum);
	}
}
