Answer to Question #274482 in Java | JSP | JSF for kkkkkk

Question #274482

All years that are evenly divisible by 400 or are evenly



divisible by four and not evenly divisible by 100 are



leap years. For example, since 1600 is evenly divisible



by 400, the year is was a leap year. Similarly, since



1988 is evenly divisible by four but not by 100, the year



1988 was also a leap year. Using this information write



a Java method that accepts the year as user input,



determines if the year is a leap year, and displays an



appropriate message that tells the user if the entered



year is or is not a leap year.



Note: Use if Control statement


1
Expert's answer
2021-12-02T18:50:34-0500
import java.util.Scanner;
public class Main {
   public static void main(String[] args){
      int Y;
      System.out.println("Enter a Year :: ");
      Scanner input = new Scanner(System.in);
      Y = input.nextInt();


      if (((Y % 4 == 0) && (Y % 100!= 0)) || (Y%400 == 0))
         System.out.println(Y+" is a leap year");
      else
         System.out.println(Y+" is not a leap year");
   }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS