We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • Practice
  • Certification
  • Compete
  • Career Fair
  • Hiring developers?
  1. Practice
  2. Java
  3. Introduction
  4. Java If-Else
  5. Discussions

Java If-Else

Problem
Submissions
Leaderboard
Discussions
Editorial

    You are viewing a single comment's thread. Return to all comments →

  • reshmav912 4 years ago+ 0 comments

    import java.io.; import java.util.;

    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 && n<=5 ){
                       ans= "Not Weird";
                    }
                    else if (n>=6 && n<=20){
                        ans = "Weird";
                    }
                    else if(n>20) {
                        ans = "Not Weird";
                    }
                }
            }
            else{
                ans="Invalid no! Enter a number between 1 and 100.";
            }
    
            System.out.println(ans);
    
        }
    }
    
    6|
    ParentPermalink
  • Contest Calendar
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature