would this work
A year is a leap year if it is exactly divisible by 4, unless it is exactly divisible by 100 in which case it is only a leap year if it is exactly divisible by 400.
Design, implement and test a program to input a year and output whether it is a leap year.
import java.util.*;
public class LeapYear
{
public static void main(String[] args)
{
Scanner kybd = new Scanner(System.in);
System.out.println("Enter A Year");
int Year;
Year=kybd.nextInt();
if ((Year%4)=0)
System.out.println("The year" + Year + "is a leap year");
else
System.out.println("The year is not a leap year");
}
}
I'm not sure, because of the info about being divisible by 100 part.
|