public class Suma { public static void main(String [] args) throws IOException { BufferedReader in=new BufferedReader(new InputStreamReader (System.in)); int num1; int num2; int suma; int indice=1; System.out.println("Escribe un numero para sumar: "); num1= Integer.valueOf(in.readLine().trim()).intValue(); System.out.println("Escribe otro numero para sumar: "); num2= Integer.valueOf(in.readLine().trim()).intValue(); suma= num1+num2; System.out.println(indice+" suma = "+suma); for (indice=2; suma>0; indice++) { System.out.println("Escribe otro numero para sumar: "); num2= Integer.valueOf(in.readLine().trim()).intValue(); suma+=num2; System.out.println(indice+" sumas = "+suma); } } }