LeapYear program crashes.
Code:
import java.util.Scanner;
public class Leap_Year
{ public static void main(String[] args)
{ Scanner in = new Scanner (System.in);
System.out.println("Imput your year");
int year = in.nextInt();
int leapyear1 = year % 4;
int leapyear2 = year % 400;
int leapyear3 = year % 100;
if (leapyear2 == 0)
System.out.println("It is a leapyear");
else if (leapyear3 == 0)
System.out.println("It is not a leapyear");
else if (leapyear1 == 0)
System.out.println("It is not a leapyear");
}
}
So, I am trying to create a program that will tell whether or not the inputted number is a leap year or not, but my program crashes when a number like 567 is inputted. What is wrong with my code?