Program 8 :: LeapYear

// Program :: Write a Java Program to finding the LeapYear
import java.io.*;

public class LeapYear {
public static boolean isLeapYear(int year)
{
if( year % 4 != 0 ){
return false;
}

if(( year % 400 != 0 ) && (year % 100 == 0)){
return false;
}else{
return true;
}
}

public static void main (String[] args){
int year = 0;
String input = “”;
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
while(true){
System.out.println(“Enter the year: “);
try {
input = in.readLine();
year = Integer.valueOf( input ).intValue();
} catch (IOException e) {
e.printStackTrace();
}
if(year < 0){break;}
System.out.print (“Is it a leap year? “);
System.out.println( isLeapYear(year) );
}
}
}
// Engr. Parag Ferdus 01713 400 421, 01914 949 399, 01670 876 388
// www.pfbd.yolasite.com paragferdus@gmail.com

Leave a Comment

Your email address will not be published.