Description
File Name:

H:\CPSC1150\Lab6\LeapYear.java 
Purpose

To calculate whether the given year is a leap year. If it is, then what day February 29^{th } is on.
. 
Input

The year 
Output

If it is a leap year or not. If it is then what day February 29^{th} is on 
Program Logic (Pseudocode)
Algorithm LeapYear
Start
(main method)
 Initialize variables
(a) day = 29 in int
(b) month = 2 in int
(c) year in int (user input)
 Allow the user to enter a year
(a) check to make sure the year is after 1582
(b) if is after 1582 take it to the (is_leap_year method)
(c) return whether the year is a leap year or not
 if the year is a leap year
(a)Take it to the (zellers mtehod) and give it the day, month, and year
(b) take daynumber and enter it in (week_day method)
(c) Inform user what day February 29^{th} lies on
 Create a loop to find the next year with February 29^{th} occurring on the same day
(a) The loop parameters should be the year1 starting 4 years after the given year and increases by 4
(b) Put year1 into the (zellers method) and return as daynumber1
(c) check if the daynumber=daynumber1 and check if year1 is a leap year (is_leap_year method)
(d) if it is the same display to the user and exit loop
(is_leap_year method)
 Check if it is a leap year and return a Boolean of true if it is and false if it isn’t
 If year%4 equals 0
 If the year%100 does not equal 0
 And if the year%400 equals 0
(zellers method)
 Define Terms
 Let DAY an integer number representing the day of the month
 Let MONTH an integer number representing the month
 Let YEAR be an integer number representing the year
 Let DayNumber be the an integer number representing the day of the week( 0 represents Sunday, 6 represents Saturday)
 Let StartMonth, StartYear, and LeapFactor be three integer variables used in the calculation
 INITIALIZE Variables
 Set DAY , MONTH and YEAR to the date you want to find the week day
 IF MONTH < 3
2.1 StartMonth = 0
2.2 StartYear = YEAR – 1
otherwise
2.1 StartMonth = INT (0.4 * MONTH + 2.3)
2.2 StartYear = YEAR
(a)LeapFactor = (StartYear / 4) – (StartYear / 100) + (StartYear / 400)
(b)DayNumber = ((365 * YEAR + 31 * (MONTH – 1) + DAY + LeapFactor – StartMonth) – 1) MOD 7
(c) return daynumber
(week_day method)
1.Create a switch statement
(a) set each number to a day with the numbers between 0 and 6
(b) return the given day in string