Advertisement
Mhazard

JAVA Leap Year WIP

Oct 17th, 2015
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.32 KB | None | 0 0
  1. // 15101194S
  2.  
  3. //Import Scanner
  4. import java.util.Scanner;
  5. public class LeapYears
  6. {
  7.         public static void main(String[] args)
  8.         {
  9.                     //Title
  10.                     System.out.println("Leap Year Calculation");
  11.                 //Scanner
  12.                 Scanner sc = new Scanner(System.in);
  13.                 //Insert Values
  14.                 System.out.print("Enter The Year: ");
  15.                 int Year = sc.nextInt();
  16.                 //Calculation
  17.                 int LeapYear = Year % 4;
  18.                 int LeapYear2 = Year % 100;
  19.                 int LeapYear3 = Year % 400;
  20.                 //Output
  21.                 if (LeapYear > 0)
  22.                     if ((LeapYear == 0 && LeapYear2 != 0) || LeapYear3 == 0)
  23.                     {
  24.                           System.out.println(Year + " is a leap year");
  25.                           System.out.println("The numbers of days in" + Year + "is 366.");
  26.                 }
  27.                 else {
  28.                        System.out.println(Year + " is NOT a leap year");
  29.                        System.out.println("The numbers of days in" + Year + "is 365.");        
  30.                 }
  31.                 //Output Invalid
  32.                 if (Year <= 0) {
  33.                     System.out.println("Invalid Input");
  34.                 }
  35.                 //Closing
  36.                 }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement