You are viewing a single comment's thread. Return to all comments →
getting error for test case 2: In which for digit 4 error is showing.
can you explain why is so?
import java.util.Scanner; public class Solution {
public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); String ans=""; if(n>=1 && n<=100) { if(n%2==1){ ans = "Weird"; }else if(n%2==0){ if (n>=2 && n<=5){ ans = "not Weird"; }else if (n>=6 && n<=20){ ans = "Weird"; }else if (n>20){ ans = "Not Weird"; } } }else{ ans = "Invalid"; } System.out.println(ans); }
}
Java If-Else
You are viewing a single comment's thread. Return to all comments →
getting error for test case 2: In which for digit 4 error is showing.
can you explain why is so?
import java.util.Scanner; public class Solution {
}