Pages

Sunday 20 November 2016

Problem 32 - Kabisat

  1. public class DetermineLeapYearExample {
  2.  
  3.         public static void main(String[] args) {
  4.                
  5.                 //year we want to check
  6.                 int year = 2004;
  7.                
  8.                 //if year is divisible by 4, it is a leap year
  9.                
  10.                 if((year % 400 == 0) || ((year % 4 == 0) && (year % 100 != 0)))
  11.                         System.out.println("Year " + year + " is a leap year");
  12.                 else
  13.                         System.out.println("Year " + year + " is not a leap year");
  14.         }
  15. }

0 comments:

Post a Comment