import java.io.*;

public class DoWhile

{

	public static void main (String args []) throws IOException

	{

	//uses dowhile loop to add a series of positive numbers together
	//will run at least once through the body of the the do loop 

		int nextnumber, sum, count;

	// to check whether to exit dowile loop
	String response = new String("Y");
	
	//Create a bufferreader object to rd to read the InputStringReader
	BufferedReader in=new BufferedReader (new InputStreamReader(System.in));

	String s=new String();
	nextnumber = 0;	
	sum=0;
	count=0; // initialise count

	do

	{
		System.out.println("Enter the next number");
		System.out.flush();
		s=in.readLine();//readin the users input	
	
		//assign it to nextnumber
		nextnumber = Integer.parseInt(s);
		count++;  // increments by 1 . First time set to 0
		sum+=nextnumber;

		System.out.println ("Want to continue? Enter Y , anything else to Quit");
		System.out.flush();
		response = in.readLine();

		System.out.println("You said = " + response);
		System.out.flush();

	}while (response.equalsIgnoreCase("Y"));

	System.out.println(" You have added togeter = " + count + " numbers");
	System.out.println("The total is " + sum);
	}

}//ends class