//The following three lines are needed to get a number from the keyboard. import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class FourWayLeap { public static void main(String[] args) { System.out.print("What year is this? "); int year = getInt(); if (year % 400 == 0) { System.out.println(year + " is a leap year."); } else if (year % 100 == 0) { System.out.println(year + " is not a leap year."); } else if (year % 4 == 0) { System.out.println(year + " is a leap year."); } else { System.out.println(year + " is not a leap year."); } } //The following 16 lines are needed to get a number from the keyboard. private static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); private static int getInt() { try { return Integer.parseInt(reader.readLine()); } catch (IOException e) { System.err.println("Couldn't receive input: " + e.getMessage()); } catch (NumberFormatException e) { System.err.println(e.getMessage() + ", the characters were not a number."); } return 0; } }