Simpleinput problem

i am getting the output.but where to insert the condition that all input nos should be between -1000 to 1000.

import java.util.Scanner; public class Simpleinput { public static void main(String[] args) { int n,t,s=0; int a[]=new int[1000]; int b[]=new int[1000]; Scanner sc = new Scanner(System.in); System.out.println(“Enter value of n”); n = sc.nextInt(); for(int i=1;i<=n;i++) { t=sc.nextInt(); s=s+t; a[i]=s; b[i]=t; } for(int j=1;j<=n;j++) { if(a[j]>0) { System.out.println(b[j]); } else break; } } }

Hi @Ridz030,
You needn’t insert the condition. It is a constraint. The testcase will be designed such that they take care of this.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.