So I'm trying to do a school project (a simple leap year tester) but my boolean statements do not seem to be working. My code looks like:
public class Year{
int year_input;
public Year(int year_input){
}
public boolean isLeapYear(){
// your code here
if (year_input % 4 ==0){
return true;
}
else{
return false;
}
}
}
And it has to work with the included class:
import java.util.Scanner;
public class LeapYearTester{
public static void main(String[] args){
Scanner input = new Scanner(System.in);
System.out.println("Please enter a year");
int year_input = input.nextInt();
Year theYear = new Year(year_input);
if (theYear.isLeapYear())
System.out.println("That's a leap year!");
else
System.out.println("That's not a leap year!");
}
}
But for some reason, but console is saying that all years are leap years, even if they're obviously not. False Leap Years (Picture)
Any help?