Monday, 11 March 2013

21. Program for find leap year or not



import java.util.*;
class find
{
            Scanner sc=new Scanner(System.in);
            int n;
            void Getyr()
            {
                       
                        n=sc.nextInt();
            }
            void calculate()
            {
                        if(n%100==0)
                        {
                                    if(n%400==0)
                                    System.out.println("Leap Year");
                                    else
                                    System.out.println("Not leap Year");
                        }         
                        else
                        {
                                    if(n%4==0)
                                    System.out.println("Leap Year");
                                    else
                                    System.out.println("Not leap Year");
                        }
            }
}
class leapyear
{
            public static void main(String args[])
            {
                        System.out.println("Enter the year:");
                        find ob=new find();
                        ob.Getyr();
                        ob.calculate();
            }
}

No comments:

Post a Comment