• Skip to primary navigation
  • Skip to content
  • Skip to primary sidebar

Aspiration Classes

  • Join Now
  • contact@aspirationclassess.com
  • +91 9831 913 909

Main navigation

  • Home
  • About Us
  • Subjects Taught
  • Resources
    • ICSE
      • ICSE Computer Applications
      • ICSE Chemistry
      • ICSE Biology
      • ICSE Chemistry
      • ICSE Commerce
      • ICSE Maths
      • ICSE Physics
    • ISC
      • ISC Computer
      • ISC Physics
      • ISC Chemistry
      • ISC Maths
      • ISC Accounts
      • ISC Biology
  • Notice
  • Contact Us

Blog

Home / ICSE / Write a program in Java to input a year and print whether it is a leap year or not.
  • ICSE
  • ICSE Computer Applications

Write a program in Java to input a year and print whether it is a leap year or not.

By Faseel Anwar - 14/05/2015

A leap year has 366 days, as opposed to a common year, which has 365. Nearly every 4 years is a Leap Year, and we add a Leap Day, an extra – or intercalary – day on February 29.

Leap Years are needed to keep our modern day Gregorian Calendar in alignment with the Earth’s revolutions around the sun. It takes the Earth approximately 365.242199 days – or 365 days, 5 hours, 48 minutes, and 46 seconds – to circle once around the Sun. This is called a tropical year.

However, the Gregorian calendar has only 365 days in a year, so if we didn’t add a day on February 29 nearly every 4 years, we would lose almost six hours off our calendar every year. After only 100 years, our calendar would be off by approximately 24 days!

In the Gregorian calendar 3 criteria must be taken into account to identify leap years:

  • The year is evenly divisible by 4;
  • If the year can be evenly divided by 100, it is NOT a leap year, unless;
  • The year is also evenly divisible by 400. Then it is a leap year.

This means that 2000 and 2400 are leap years, while 1800, 1900, 2100, 2200, 2300 and 2500 are NOT leap years.

The year 2000 was somewhat special as it was the first instance when the third criterion was used in most parts of the world since the transition from the Julian to the Gregorian Calendar.

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import java.io.*;
public class Leap
{
    public static void main(String args[])throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int y;
        System.out.println("Enter a year: ");
        y = Integer.parseInt(br.readLine());
        if(y%4==0 && y%100!=0 || y%400==0)
        System.out.println("The year is a leap year");
        else
        System.out.println("The year is not a leap year");
    }
}

Related Posts

  • Sample ISC Practical Question SolvedWrite a program in QBASIC to input the temperature in Fahrenheit and print it in Celcius
  • Class 11 – NoticeClass 11 – Notice
  • ICSE Mock Papers 2017ICSE Mock Papers 2017

Share this:

  • Click to share on Twitter (Opens in new window)
  • Click to share on Facebook (Opens in new window)
  • Click to share on Google+ (Opens in new window)

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Find us on facebook

Facebook By Weblizar Powered By Weblizar

Search the website

Recent Posts

  • ICSE Maths Mock Test Paper – 2
  • ICSE Maths Mock Test Paper – 3
  • Write a program to implement an array based Dequeue
  • Write a program to implement an array based queue
  • Write a program to implement an array based STACK

Recent Comments

  • ICSE Maths Mock Test Paper - 3 on ICSE Maths Mock Test Paper – 2
  • ICSE Maths Mock Question paper on ICSE Maths Mock Test Paper – 2
  • ICSE Maths Mock Test Paper - 2 on ICSE Maths Mock Question paper
  • ICSE Commercial Application Mock Question paper on ICSE Commercial Studies Mock Question paper – 1
  • ICSE Chemistry Mock Question paper 1 - Aspiration Classes on ICSE Chemistry – Analysis and Marking Scheme 2017

Categories

  • Engineering (2)
  • ICSE (114)
  • ICSE Biology (2)
  • ICSE Chemistry (7)
  • ICSE Commerce (4)
  • ICSE Computer Applications (108)
  • ICSE Economics (2)
  • ICSE English (2)
  • ICSE Maths (8)
  • ICSE Physics (7)
  • ISC (84)
  • ISC Accounts (3)
  • ISC Biology (2)
  • ISC Chemistry (7)
  • ISC Commerce (1)
  • ISC Computer (71)
  • ISC Economics (1)
  • ISC English (1)
  • ISC Maths (6)
  • ISC Physics (12)
  • Notices (9)
  • Others (16)
  • Uncategorized (1)

ISC POPULAR POSTS

Write a program to implement an array based Dequeue

February 22, 2018

Write a program to implement an array based queue

February 22, 2018

Write a program to implement an array based STACK

February 22, 2018

ICSE POPULAR POSTS

ICSE Maths Mock Test Paper – 2

February 25, 2018

ICSE Maths Mock Test Paper – 3

February 25, 2018

ICSE Commercial Application Mock Question paper – 1

February 19, 2018

OTHER POPULAR POSTS

Write a program to implement an array based Dequeue

February 22, 2018

Write a program to implement an array based queue

February 22, 2018

Write a program to implement an array based STACK

February 22, 2018
ABOUT US
Aspiration Classes is a venture of like minded people from various backgrounds who seek to provide high quality assistance to school and college going students.
Contact us: contact@aspirationclasses.com
FOLLOW US
  • Disclaimer
  • Privacy Policy
  • Advertisement
  • Contact Us

© Copyright 2017 - Designed & Developed by Waqqas Salam