lea year come after 4 years next. like 2020 is a leap year after 2024 will be leap year.
Go to the java series.: https://browncodeit.blogspot.com/p/java-programs.html
Source Code:
- public class LeapYearDemo {
- public static void main(String[] args) {
- try (
- Scanner input = new Scanner(System.in)) {
- int yr;
- System.out.print("Enter the year: ");
- yr = input.nextInt();
- if(yr%400==0 ||(yr%100 != 0 && yr%4==0)) {
- System.out.println("This is Leapyear.");
- }
- else {
- System.out.println("this is not leapyear.");
- }
- }
- }
- }
Output:
Enter the year: 2020
This is Leapyear.
Enter the year: 1589
this is not leapyear.
0 comments:
Post a Comment