You are viewing a single comment's thread. Return to all comments →
int N = scanner.nextInt(); if(N % 2 ==1 || ( N>2 && N<5)){ System.out.print("Weird"); }else if(N % 2 ==0 || (N>6 && N<20)){ System.out.print("Not Weird"); } else if (N>20){ System.out.print("Not Weird"); } }
In this 3 test cases were failed. when i give 4 as input im getting output as "Weird". But, for 4 output should be weired. plz help me in this.
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 →
int N = scanner.nextInt(); if(N % 2 ==1 || ( N>2 && N<5)){ System.out.print("Weird"); }else if(N % 2 ==0 || (N>6 && N<20)){ System.out.print("Not Weird"); } else if (N>20){ System.out.print("Not Weird"); } }