Padd Solutions

Converted by Falcon Hive

//The rules for whether or not a year is a leap year are these:
//If the year is evenly divisible by 4, it is a leap year;
//unless it is also evenly by 100, then it's not; unless it is also evenly divisible by 200, then it is.

import java.util.Scanner;

public class LeapYear
{
    public static void main (String[] args)
    {
        Scanner blah = new Scanner (System.in);
       
        int year, remain, hundred, fourhundred;
       
        System.out.println ("Please enter a year for the Leap Year check: ");
        year = blah.nextInt ();
       
        remain = (year % 4);
       
        hundred = (year % 100);
       
        fourhundred = (year % 400);
       
        if (remain == 0)
        {
            if (hundred == 0)
            {
             if (fourhundred == 0)
             {
                System.out.println ("This is a leap year.");
             }
            
             else
             {
                 System.out.println ("This is not a leap year.");
             }
            }
            else
            {
                System.out.println ("This is a leap year.");
            }
        }
        else
        {
            System.out.println ("This is not a leap year.");
        }
    }
}

(0) Comments

Post a Comment