My issue
int x=scan.nextInt();
int y=scan.nextInt();
if(x+y>6)
{
System.out.print("YES");
}
else{
System.out.print("NO");
}
My code
/* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner scan=new Scanner(System.in);
int x=scan.nextInt();
int y=scan.nextInt();
if(x+y>6)
{
System.out.print("YES");
}
else{
System.out.print("NO");
}
}
}
Problem Link: GDTURN Problem - CodeChef
@kvenkat1436 U have to write your code in test case loop.
Like this.
/* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
for(int i=0;i<t;i++){
int n1=sc.nextInt();
int n2=sc.nextInt();
if((n1+n2)>6)
{
System.out.println("YES");
}
else
{
System.out.println("NO");
}
}
}
}
The problem in your code is you’re taking the values of x and y only once. You have to initiate a loop for the number of test cases and take the values of x and y inside that loop. That will solve your problem.