You are viewing a single comment's thread. Return to all comments →
import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); String ans=""; if(n%2==1){ ans = "Weird"; } else{ if(2<n && n<=5){ans="Not Weird";} if(6<n && n<=20){ans="Weird";} if(n>20){ans="Not Weird";} } System.out.println(ans); } }
Here, we check if the input is odd in the first step and go for even and ranges in the next step.
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 →
Here, we check if the input is odd in the first step and go for even and ranges in the next step.