Answer:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
while (true) {
System.out.print("Enter a year (0 to exit): ");
int year = scan.nextInt();
if (year == 0) break;
boolean leap = false;
if (year % 4 == 0) {
if (year % 100 == 0) {
leap = (year % 400 == 0);
}
else {
leap = true;
}
}
System.out.printf("%d is%s a leap year.\\", year, leap ? "":" not");
}
}
}