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




Have Programming Question? Ask it here!
 
 
 


nitesh kumar dwivedi
leap
1 Answer(s)      3 years and a month 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
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
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
Leap Year Program
the user if it's a leap year or not. It uses boolean operators instead... whether a give year is leap year or not. // Michael Maus, 22 Sept 2004 import... String leapResult; // Tell's whether it's a leap year
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
calender
calender  to calculate date of expiry if date of manufacture is given,considering it may be leap year or may
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
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
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
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
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
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
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
How to design a water drop.
have to open a leap picture to show a water drop effect on the leap as I have
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
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
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
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
Java Help Please
date. (Don't forget about the end of a month. Ignore leap years.). d. Input
PHPeclipse
stopping you from taking that leap of faith and casting your trusty text editor
raaz
; if the user enters ??2?? the program will ask the user if it is a leap year...,"Is this a leap year?"); if(str.equalsIgnoreCase("yes")){ days=29
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
roov
the program; if the user enters ??2?? the program will ask the user if it is a leap...??2?? the program will ask the user if it is a leap year. If the answer from... 2: String str=JOptionPane.showInputDialog(null,"Is this a leap year
raaz
; if the user enters ??2?? the program will ask the user if it is a leap year...?? the program will ask the user if it is a leap year. If the answer from the user is ...: String str=JOptionPane.showInputDialog(null,"Is this a leap year
Java Find Next Date Example
. In this example we will handle the leap year also. To create this application I... for finding their values. I have created a method for checking the leap year which will check the input year whether the input is a leap year
Rational Method Composer
Represents a quantum leap forward in providing IBM process solutions
Java Script Code of Calendar and Date Picker or Popup Calendar
and in a leap year monthMaxDays = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31...); } function getDaysPerMonth(month, year) { /* Check for leap year. These are some conditions to check year is leap year or not... 1.Years evenly
idate()
1 for leap year, 0 otherwise m - Month number s - Seconds t
Date Java - Java Beginners
] ) return testDay; // check for leap year if ( month == 2 && testDay == 29
LINUX SHELL SCRIPT - Date Calendar
in any month. o Assume that it is not a leap year, so the number of days in any
Java: Weaknesses
2 series (1.2, 1.3, and 1.4), and a mysterious leap in numbering to Java 5
Khandala and Lonavala Hill Stations
;s Leap. To look after the accommodation needs there are accommodations
Date validation in JSP
special validation is done(i.e if it is a leap year then day 29 is valid and if it is not a leap year then 29 days are not valid) If at time of inserting... if it is not a leap year and if it a leap year then user can insert '29'  If entered
gmdate()
- The number of days in the given month L - Whether it's a leap year (1 if it is a leap year, 0 otherwise) o - The ISO-8601 year number Y - A four digit
I need help in doing this. - Java Beginners
)) { System.out.print(year + " is a leap year"); isLeap = true; } else System.out.println(year + " is not a leap year"); System.out.flush(); return isLeap
Two compilation errors.Can anyone help soon. - Java Beginners
;= daysPerMonth[ month ] ) return testDay; // check for leap year
Various time classes
Java NotesVarious time classes Solving all the date and time problems is a tough job (different calendar systems, time zones, date formats, date arithmetic, leap seconds, ...). You will find several classes useful for handling
Fail Early, Fail Often
the program to slowly fall apart. Perhaps the greatest leap that Java made over
Database books Page1
to storing data in tabular form. It?s not much of a stretch to make the leap
Advertisements
 

 

 

DMCA.com