Giter Club home page Giter Club logo

leap_years's Introduction

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.

##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;

leap_years's People

Contributors

merttalug avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.