Given a list of numbers, stop processing input after the cumulative sum of all the input becomes negative.
here is the question and following is my codeimport java.util.*;
public class Main {
public static void main(String args[]) {
Scanner var=new Scanner(System.in);
int sum=0;
while(sum>=0) {
int n=var.nextInt();
System.out.println(n);
sum=sum+n;
}
}
}