Tuesday, 17 May 2016

Task
Given an integer, , perform the following conditional actions:

  • If is odd, print
  • If is even and in the inclusive range of to , print
  • If is even and in the inclusive range of to , print
  • If is even and greater than , print
Complete the stub code provided in your editor to print whether or not is weird.


1 comment:

  1. 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(n%2==0)
    {
    if(n==2 && n==4 )
    {
    ans = "Not Weird";
    }
    else if(n > 20)
    {
    ans = "Not Weird";
    }
    }
    }
    System.out.println(ans);

    }
    }

    ReplyDelete