Sort by

recency

|

2049 Discussions

|

  • + 0 comments

    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])?");
    
        if (N%2==0 && N >= 2 && N <= 5){
            System.out.println("Not Weird");
        }else if(N%2==0 && N == 6 && N <= 20){
            System.out.println("Weird");
        }else if(N%2==0 && N > 20){
            System.out.println("Not Weird");
        }else{
            System.out.println("Weird");
        }
    
        scanner.close();
    
    }
    
  • + 0 comments

    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 {

    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])?");
    
        scanner.close();
        if ((N%2 == 1)||(N%2 == 0 && N >= 6 && N <= 20)){
            System.out.println("Weird");
        }
        else {
            System.out.println("Not Weird");
        }
    }
    

    }

  • + 0 comments

    String str = ""; if(N%2!=0 || (N>=6 && N<=20)){ str = "Weird"; }else{ str = "Not Weird"; } System.out.println(str);

  • + 0 comments

    For Java15 Platform

    I wrote the code from scratch just to get more practice

    import java.util.Scanner;
    
    class Solution
    {
        public static void main(String args[])
        {
            Scanner sc = new Scanner(System.in);
            int n = sc.nextInt();
            sc.close();
            
            if(n % 2 != 0)
                System.out.println("Weird");
            else
            {
                if(n>=2 && n<=5)
                    System.out.println("Not Weird");
                else if(n>=6 && n<=20)
                    System.out.println("Weird");
                else
                    System.out.println("Not Weird");
            }
        }
    }
    
  • + 0 comments

    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 {

    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])?");
        if(N%2!=0){
          System.out.print("weird");
        }else if(N>=2 && N<=5){
          System.out.print("not weird");
        }else if(N>=6 && N<=20){
          System.out.print("weird");
        }else{
          System.out.print("not weird");
        }
        scanner.close();
    }
    

    }