We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Java
- Introduction
- Java If-Else
- Discussions
Java If-Else
Java If-Else
Sort by
recency
|
1977 Discussions
|
Please Login in order to post a comment
import java.util.*;
public class Solution { private static final Scanner scanner = new Scanner(System.in);
}
import java.io.; import java.math.; import java.security.; import java.text.; import java.util.; import java.util.concurrent.; import java.util.regex.*; public class Solution {
}
import java.io.; import java.math.; import java.security.; import java.text.; import java.util.; import java.util.concurrent.; import java.util.regex.*;
public class Solution {
}
If N is passed it a Even Number . Then check other condition of Range * then check N < 5 check the Event number from 2 to 5 between and Print " Not Weird" *Else If If the N is greater then 5 and less or equal to 20 then N<= 20 condtion check it. * If the N is greate then 20 the Esle condition is print If the Number is not pass the N % 2 == 0 that condition then print the Outer Else statement.
if(N % 2 == 0 ){ if(N<5){
scanner.close(); }
//Took me FOREVER>:( but i finaly did it :D
public static void main(String[] args) { int N = scanner.nextInt(); scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?"); if ((N % 2) == 0 && N >= 2 && N <= 5) { System.out.println("Not Weird");
} if ((N % 2) == 0 && N >= 6 && N <= 20) { System.out.println("Weird"); } if ((N % 2) == 0 && N > 20) { System.out.println("Not Weird"); } if ((N % 2) == 1) { System.out.println("Weird"); }