The code is able to give output correctly and it is also a infinite loop which means user can enter multiple values and still get the desired output. Alas, it fails to fail to satisfy the conditions mentioned. why?
package com.codegym.task.task04.task0442;
/*
Adding
*/
import java.io.*;
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader x = new BufferedReader(new InputStreamReader(System.in));
int count=0;
for (int i=0; i>=0; i++){
String Num = x.readLine();
int n = Integer.parseInt(Num);
count = count+n;
while(n==-1)
break;
System.out.println(count);
}
}
}