Sample program


    Write program to check the year Leap year or not.
import java.io.*;
public class DemoLeap
{ public static void main(String args[])throws IO
Exception
{ InputStreamReader isr=new InputStreamReader
(System.in);
BufferedReader br=new BufferedReader(isr);
System.out.println("Input year");
int y=Integer.parseInt(br.readLine());
if(y%100==0)//check for century year
{ if(y%400==0)
{ System.out.println("Leap");
}
else
{ System.out.println("Not Leap");
}
}
else
{ if(y%4==0)
{ System.out.println("Leap");
}
else
{ System.out.println("Not Leap");
}
}
}//main
}//class

No comments:

Post a Comment

what is chain constructor in java

  In Java, chain constructor refers to a technique where one constructor calls another constructor within the same class. This is achieved b...