Very new to programming. I know this question will be very easy to answer for experienced programmers. I would like to continue running this program which finds leap years until the user enter "n." The program terminates before being able to enter y/n. Help is very much appreciated... thank you.
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
String another = "y";
Scanner scan = new Scanner(System.in);
System.out.print("Please enter a year ");
int year = scan.nextInt();
while (another.equals("y")) {
if (year < 1582) {
System.out.println("Not an established Gregorian year.");
} else if (year % 4 != 0 || (year % 100 == 0 && year % 400 != 0)) {
System.out.println("Not a leap year");
} else {
System.out.println("Leap year!");
}
System.out.println();
System.out.print("Test another year (y/n)?");
another = scan.nextLine();
}
}
}