Saturday, October 6, 2012

Java Exercise #14: Leap Year

A year is a leap year if it is divisible by 4 but not by 400 or if it is divisible by 400.

Exercise: write a program that lets the user enter a year and checks whether it is a leap year?

Enter a year: 2008
2008 is a leap year? true
Enter a year: 2002
2008 is a leap year? false

Download Code: Leap Year

No comments:

Post a Comment