import java.util.Scanner;
public class Hw2JamesVaughn {
public static void main(String[] args){
Scanner input = new Scanner(System.in);
System.out.print("Enter a year: ");
int year = input.nextInt();
if((year < 1582) == (year % 4==0))
System.out.println(year + " is a leap year");
else
System.out.println(year + " is not a leap year");
if((year > 1582) == (year % 100 != 0) || (year % 400 == 0))
System.out.println(year + " is a leap year");
else
System.out.println(year + " is not a leap year");
}
}
This is the assignment.
(To determine if a particular year is a leap year, use the following logic:
- the year must be divisible by 4
- starting from 1582, if the year is divisible by 100, it must also be divisible by 400 Thus, the year 1700 is not a leap year, but 2000 is. However, 1500 is leap year since it was before 1582, the adoption year of Gregorian calendar. Your program will ask for a year, and then display whether the year is leap year or not.)
I have gotten this far with my java leap year program but its not working! Ive been working on this and i have no idea what is wrong.