Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/merttalug/leap_years
Program to find whether the year the user entered is a leap year with Java
https://github.com/merttalug/leap_years
java kodluyoruz leap-year patika-dev
Last synced: about 2 hours ago
JSON representation
Program to find whether the year the user entered is a leap year with Java
- Host: GitHub
- URL: https://github.com/merttalug/leap_years
- Owner: merttalug
- License: mit
- Created: 2022-03-07T12:24:37.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-03-07T12:32:18.000Z (almost 3 years ago)
- Last Synced: 2024-11-05T11:32:41.189Z (about 2 months ago)
- Topics: java, kodluyoruz, leap-year, patika-dev
- Language: Java
- Homepage:
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Leap_Years
Program to find whether the year the user entered is a leap year with Java## What is a leap year?
A leap year is a year with 366 days instead of 365 in the Gregorian calendar. This extra day (leap day) is obtained by adding February 29 to February, which is normally 28 days.
![](https://c.tadst.com/gfx/600x337/leap-year-calculation.png?1)
##How is a leap year calculated?
As a general rule, leap years are years that are a multiple of 4:
* Like 1988, 1992, 1996, 2000, 2004, 2008, 2012, 2016, 2020, 2024.
Years that are a multiple of 100 are leap years that are only divisible by 400 without a remainder:
* For example, the years 1200, 1600, 2000 are leap years, but 1700, 1800, and 1900 are not leap years.
The reason why only those exactly divisible by 400 are considered leap years is to correct the error that an astronomical year is approximately 365.242 days, not 365.25 days.```
leap4 = year % 4;
leap100 = year % 100;
leap400 = year % 400;```
```
if (leap4 == 0) {
if (leap100 == 0) {
if (leap400 == 0) {
isError = false;
} else isError = true;
} else isError = false;}
else isError = true;```