leap year logic with && and ||
import java.util.*;/**
* leapyear
*/
public class leapyear {
public static void main(String[] args) {
int y;
Scanner s= new Scanner (System.in);
System.out.println("Enter The year");
y=s.nextInt();
if((y%4==0&&y%100!=0)||(y%4==0&&y%100==0&&y%400==0)){
System.out.println("This is leap year");
}
else{
System.out.println("not a leap year");
}
}
}
Output :=
Comments
Post a Comment