Hey bro,you have done many mistakes,there many errors in your program, such as:
1>there is no such thing as import java.util in java,either import the whole package’s classes by import java.util.*; or import the specific class ie import java.util.classname;
same for other importing statements also.
2>in while loop it should be a decreament operator,ie you should have written,
while((t–)>0) ,like this,not a only neg(-) sign
3>if you are printing the string ,then we do not put this (“Yes”),but we put this (“Yes”) ,diff… of braces(or what you want it to call)
4>always try to enclose the code with try and catch block to prevent the NZEC exception.
Correct prog acc to you would be :-
import java.util.;
import java.lang.;
import java.io.*;
public class Main
{
public static void main (String[] args)
{
Scanner sc = new Scanner(System.in);
try
{
int t = sc.nextInt();
while((t–)>0){
int n = sc.nextInt();
int c = sc.nextInt();
int[] a = new int[n];
int flag = 0;
for(int i =0 ; i<a.length ; i++){
a[i] = sc.nextInt();
c = c-a[i];
if(c<=0){
flag=1;
}
}
if(flag==0){
System.out.println(“Yes”);
}
else{
System.out.println(“No”);
}
}
}
catch(Exception e)
{
return e;
}
}
}
But I would recommend you that pls work on your basics first, do not move to questions directly, first be well versed with the basic syntax.
correct 1 mistake acc to step 1.