You are viewing a single comment's thread. Return to all comments →
Could someone tell me why my code doesn't work? I fail second test case where n equals 3.
public class Solution { private static final Scanner scanner = new Scanner(System.in); public static void main(String[] args) { int n = scanner.nextInt(); scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?"); String ans = "Weird"; if (n % 2 == 0 ||( n > 2 && n < 5)){ ans = "Not Weird"; } else if (n % 2 == 0 || ( n > 6 && n < 20 )) { ans = "Weird"; } else if (n % 2 == 0 || n > 20 ) { ans = "Not Weird"; } else { ans = "Weird"; } System.out.println(ans); } }
Seems like cookies are disabled on this browser, please enable them to open this website
Java If-Else
You are viewing a single comment's thread. Return to all comments →
Could someone tell me why my code doesn't work? I fail second test case where n equals 3.