answersLogoWhite

0


Best Answer

public class LeapYear {

public static void main(String[] args) {

int year = Integer.parseInt(args[0]);

boolean isLeapYear;

// divisible by 4

isLeapYear = (year % 4 == 0);

// divisible by 4 and not 100

isLeapYear = isLeapYear && (year % 100 != 0);

// divisible by 4 and not 100 unless divisible by 400

isLeapYear = isLeapYear (year % 400 == 0);

System.out.println(isLeapYear);

}

}

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a program in java to find a leap year?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you write a program in java to check a year leap year or not and display the proper message?

You can use a number of nested "if" commands. The rules are the following: If the year is a multiple of 400, it IS a leap year. Else, if the year is a multiple of 100, it's NOT a leap year. Else, if the year is a multiple of 4, it IS a leap year. Else it's NOT a leap year. In Java, to check for divisibility, you use the "%" operator, which gives you the remainder of a division. For example: if (year % 400 = 0) ... To show results on screen, you use: System.out.println(...)


Write a shell program to check and display 10 leap years?

dono


Write a program to check whether a given year is leap year or not using ternary operator?

leap yr = ((y%100!=0 && yr %400==0)?1:(yr%4==0)?1:0; leap yr =1; printf ("leap yr"); else printf ("not leap yr");


How do you find leap year?

Find the modulo of the year by 4. If the value is 0,then it is a leap year. Otherwise it is not a leap year.


Mao's program to increase production?

Great Leap Forward


What program was intending to overcome the backwardness of China's economy technology and industry?

the Great Leap Forwardthe Great Leap Forward


Write a c program to find leep year through nested if?

// leap year by @bhi// #include<stdio.h> #include<conio.h> void main() { int year; clrscr(); printf("Enter the Year that you want to check : "); scanf("%d", &year); if(year % 400 == 0) printf("%d is a Leap Year.", year); else if(year % 100 == 0) printf("%d is not a Leap Year.", year); else if(year % 4 == 0) printf("%d is a Leap Year.", year); else printf("%d is not a Leap Year", year); printf("\nPress any key to Quit..."); getch(); }


C program to find the year is leap year or not?

Algorithm: If the year is not divisible by 4 then it is not a leap year. Else if the year is not divisible by 100 then it is a leap year. Else if the year is not divisible by 400 then is not a leap year. Else it is a leap year. Implementation: bool is_leap_year (unsigned year) { if (year%4) return false; if (year%100) return true; if (year%400) return false; return true; }


'write a program to check whether given year is a leap year or not?

#include using namespace std;int main(){short numberOfDays = 0;cout > numberOfDays;if (numberOfDays == 365){cout


What is the program in c to check whether a year is leap year or not in simple way?

If the year divides evenly by 4 it's a leap year. If it's a century year it has to divide evenly by 400. 2000 was a leap year. 2100 will not be a leap year.


C program to generate a list of leap years between 1900 -2000?

3900


How does one write the phrase Shadows Leap in Latin?

Umbrae saliunt