Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


nitesh kumar dwivedi
leap
1 Answer(s)      3 years and 9 months ago
Posted in : Java Beginners


  1. Check the given year for leap year (Test Case: 2010, 2012 , 1900)

Advertisement
View Answers

March 25, 2011 at 11:24 AM


import java.util.*;

public class LeapYear{
   public static boolean isLeapYear(int year) {

    if (year < 0) {
      return false;
    }
    if (year % 4 == 0) {
      return true;
    }  else if (year % 400 == 0) {
      return true;
    } 
    else if (year % 100 == 0) {
      return false;
    }
    else {
      return false;
    }
  }
public static void main(String[] args){
    Scanner in = new Scanner(System.in);
    System.out.println("Enter any year:" );
    int y = in.nextInt();
        LeapYear year = new LeapYear();
    if (year.isLeapYear(y)){
    System.out.println("It is a leap year.");
    }           
    else{
    System.out.println("It is not a leap year.");
    }
}
}


Related Tutorials/Questions & Answers:
leap
leap   Check the given year for leap year (Test Case: 2010, 2012 , 1900
leap year
leap year  how to create class for leap year. It is leap year...(); if (year.isLeapYear(y)){ System.out.println("It is a leap year."); } else{ System.out.println("It is not a leap year."); } } } Thanks
Advertisements
java leap year
java leap year  write a java program that takes an input... whether itis a leap year. Aleap year is an integer greater than 1584...(); if (year.isLeapYear(y)){ System.out.println("It is a leap year
leap year logic - Java Beginners
leap year logic  hi frds.. can u give me logic for leap year..  Hi Friend, Please visit the following link: http://www.roseindia.net/java/beginners/Leapyear.shtml Thanks
Java Leap Year Problem
Java Leap Year Problem  I need help with a writing a program in Java that creates a class Year that contains a data field that holds the number of months in a year and the number of days in a year. It should include a get method
Checking whether a year is leap or not
Checking whether a year is leap or not   ... for checking whether a year is a leap year or not. Here, we have taken the year 2000. So...;if else" condition. As we know leap year is divided by the integer 4 and so
Determining If a Year is a Leap Year in Java
Determining If a Year is a Leap Year in Java       Leap Year: Leap Year is the year contains an extra day. In the leap year, February month contains 29 days since normally
Listing out leap years between certain period
Listing out leap years between certain period  ... the coding for finding and listing out the leap years between two years. In the following example we have to find out the leap years between 1990 and 2006. First
Calendar
is leap or not. Description of program:  In the given example first we... of the Gregoriancalendar class and also checking whether the year is leap or not and printing
Global Positioning System advantages and disadvantages
Global Positioning System advantages and disadvantages Every coin has two sides. The same rule applies to the GPS systems. GPS systems is a latest technological leap taken, which has brought new features to the communication
arrays
arrays  Write a program to print details of all the months with number of days in a year (Leap or Non Leap year) using array of objects Integer and String
fetch data from database in javascript
fetch data from database in javascript   How to fetch data from database in JavaScript when it is a leap year
calender
calender  to calculate date of expiry if date of manufacture is given,considering it may be leap year or may
java program - Java Beginners
java program  program to find whether the given year is a LEAP YEAR... is leap year or not. public class CheckLeapYear { public static void...) { System.out.println(year + " is a Leap year."); } // Is theYear Divisible by 4
pava program - Java Beginners
pava program  program to display whether the given year is LEAP YEAR... % 100 != 0) { System.out.println(year + " is a Leap year...) { System.out.println(year + " is a Leap year."); } // It is Divisible
jsp code
jsp code  how to display date in drop down list by jsp thus the date start from current date and for next year it has to check leap year function to february then it display 30 for some months else 31 for other months
java programm
java programm  Create program, which will calculate number of days between two dates. The program has to accordance with the leap-years (do not ignore leap-years). You must NOT use any libraries to calculate the number of days
roob
Java leap year date example    Write a Java Program with file name SectionB.java using Switch control Statement The program will use... if it is a leap year. If the answer from the user is ??Yes?? it will show the message
is this programm efficient to find the day of the given date . can it be more normalized ?
,mm,yy,i,leap=0,ordi=0,odd_years,month_days= 0,total ; char week[7][10...); for(i=yy-1;i>1;i--) { if(i%4==0) { leap... %d\n",leap , ordi); odd_years = leap+ordi; odd_years = odd_years % 7
Y asked Calendar.js File For Subcombo box - Development process
// Array of max days in month in a year and in a leap year monthMaxDays = [31, 28, 31... for leap year. These are some conditions to check year is leap year or not... 1.Years evenly divisible by four are normally leap years, except for... 2.Years
You asked full source code for search - Development process
, year) { /* Check for leap year. These are some conditions to check year is leap year or not... 1.Years evenly divisible by four are normally leap years, except for... 2.Years also evenly divisible by 100 are not leap years, except
How to design a water drop.
have to open a leap picture to show a water drop effect on the leap as I have
java prog
java prog  Write a Java applet that inputs a person's date of birth (month, day, year): ? Informs the person if the year of birth is a prime number. ? Informs the person if the year of birth is a leap year. ? Computes
Operators; If, Else, Elseif; Loops
;); if ($y== “2000”) Print “This is a leap year!”; elseif ($y== “2001”) echo “Year 2000 is not a leap year!&rdquo... will output “This is a leap year!” if the current year is 2000
programes on if....else
programes on if....else   write a program to check whether entered year is leap year or not write a program to check whether entered no. ends with 5...){ System.out.println("Leap Year!"); } else{ System.out.println("Not a Leap
Java Help Please
date. (Don't forget about the end of a month. Ignore leap years.). d. Input
roob
if it is a leap year. If the answer from the user is ??Yes?? it will show the message
roob
if it is a leap year. If the answer from the user is ??Yes?? it will show the message
PHPeclipse
stopping you from taking that leap of faith and casting your trusty text editor
roov
if it is a leap year. If the answer from the user is ??Yes?? it will show...(null,"Is this a leap year?"); if(str.equalsIgnoreCase("yes
raz
the program; if the user enters ??2?? the program will ask the user if it is a leap...,"Is this a leap year?"); if(str.equalsIgnoreCase("yes")){ days=29
Advertisements
 

 

 

DMCA.com