0
what’s wrong?
import java.util.Scanner; public class Program { public static void main(String[] args) { int x=3; int y=4; int z=4; if (x>2) if(y>2) z=x+y; System.out.println("z is"+z); } } else System.out.println("x is" + x);
3 ответов
+ 2
You have problem with the curly brakets your else code is outside the class also try using curly brakets when you have more than one statement in if and else
I guess that what you are trying to do
import java.util.Scanner;
public class Program
{
public static void main(String[] args) {
int x=3;
int y=4;
int z=4;
if (x>2)
if(y>2){
z=x+y;
System.out.println("z is "+z);
}
else
System.out.println("x is " + x);
}
}
+ 1
wooow thank you i was trying to solve it for half hour thank you so much
0
You are welcome 👍🏼