My issue
in this code showing cannot find symbol
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
{
int x,y;
if(x>=2*y){
System.out.println(yes);
}else{
System.out.println(no);
}
}
}
Learning course: Practice Java
Problem Link: CodeChef: Practical coding for everyone
@prachi_thakur
Plzz refer the following solution
/* 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 hereScanner s=new Scanner(System.in);
Scanner s=new Scanner(System.in);
int x=s.nextInt();
int y=s.nextInt();
if(x>=(2*y)){
System.out.println("yes");
}
else
System.out.println("no");
}
}
Firstly, In order check for the condition you should first read the values of X and Y
inorder to read some thing in java you should use scanner package .
to use scanner package you should create object for scanner class
so you should place the following code before the if condition
Scanner sc=new Scanner(system.in);
int x =sc.nextInt();
int y =sc.next int();
I Hope this helps you