import java.util.Scanner;

/**
 * LeapYear Calculator - Check if the year you entered is a leap year.
 * See: http://www.wikihow.com/Calculate-Leap-Years 
 * @author Alvin Chao
 * @version 9-16-17
 * Acknowledgements: I have recieved no unauthorized help on this asssignment.
 */
 
public class LeapYearNested {

/**
 * Main method.
 * @param args command line arguments
 */
 
    public static void main(String[] args) {
        Scanner in;        
        int inputYear;
        boolean isLeapYear;
        final int LEAP_RATIO1 = 4;
        final int LEAP_RATIO2 = 100;
        final int LEAP_RATIO3 = 400;
        
        //Initialization
        in = new Scanner(System.in);
        System.out.print("What year is it? ");
        inputYear = in.nextInt();
        System.out.printf("\t400: %d\n", inputYear % LEAP_RATIO3);
        System.out.printf("\t100: %d\n", inputYear % LEAP_RATIO2);
        System.out.printf("\t  4: %d\n", inputYear % LEAP_RATIO1);

        isLeapYear = false;
        if (inputYear % 4  != 0) {
            isLeapYear = false;
        } else if (inputYear % 100 != 0) {
            isLeapYear = true;
        } else if (inputYear % 400 == 0) {
            isLeapYear = true;
        } 
        
        String message;
        if (isLeapYear) {
            message = "is a leap year";
        } else {
            message = "is NOT a leap year";
        }
        System.out.printf("Your year %4d %s ", inputYear, message);
    }
}
