//Import Scanner import java.util.Scanner; public class LeapYears { public static void main(String[] args) { //Title System.out.println("Leap Year Calculation"); //Scanner Scanner sc = new Scanner(System.in); //Insert Values System.out.print("Enter The Year: "); int Year = sc.nextInt(); //Calculation int LeapYear = Year % 4; int LeapYear2 = Year % 100; int LeapYear3 = Year % 400; //Output if (LeapYear > 0) if ((LeapYear == 0 && LeapYear2 != 0) || LeapYear3 == 0) { System.out.println(Year + " is a leap year"); System.out.println("The numbers of days in" + Year + "is 366."); } else { System.out.println(Year + " is NOT a leap year"); System.out.println("The numbers of days in" + Year + "is 365."); } //Output Invalid if (Year <= 0) { System.out.println("Invalid Input"); } //Closing }
Subscribe to:
Post Comments (Atom)
If the answers is incorrect or not given, you can answer the above question in the comment box. If the answers is incorrect or not given, you can answer the above question in the comment box.