avatar
sample condition if-else Java
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();            
String sample="";
if(n%2==1){
  sample = "It's old number";
}
else {
	if (n >= 2 && n <= 5) {
		sample = "Inclusive range from 2 to 5";
	} else if (n >= 6 && n <= 20) {
		sample = "Inclusive range from 6 to 20";
	} else {
		sample = "Not Weird";
	}
}
System.out.println(sample);
You need to login to do this manipulation!