I'm working on a program for school to take a year input from the user and check to see if it is a leap year or not. It should also check to see if the year is prior to 1582 and return an error if it is. I'm having an issue that if the user enters a year between [1582, 1599] that the program halts and doesn't print anything. If I change the value to 1600 it doesn't return anything between [1600, 1639]. Not sure why this behavior is happening. Any help would be appreciated.
import java.util.Scanner;
public class Leapyear
{ public static void main(String [] args)
{ Scanner Jeff = new Scanner(System.in);
//System.out.print("Run Leapyear progra? Enter true or false: ");
//boolean RunLoop$ = Jeff.nextBoolean();
System.out.print("\nPlease enter a year: ");
int Year = Jeff.nextInt();
//while(RunLoop$ = true)
if (Year <= 1582)
System.out.println("The entered year is prior to the Gregorian Callandar");
else
if (Year %4 ==0)
if (Year %400 + Year %100 ==0)
System.out.println("The entered year is a leapyear");
else
System.out.println("The Entered year is not a leapyear");
}
}
Aucun commentaire:
Enregistrer un commentaire