Skip to content

Commit

Permalink
Update APCalendar.java
Browse files Browse the repository at this point in the history
  • Loading branch information
chyeung1 authored Apr 30, 2024
1 parent 2ccae34 commit 9355f98
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/main/java/APCalendar.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ private static boolean isLeapYear(int year)
public static int numberOfLeapYears(int year1, int year2)
{
/* to be implemented in part (a) */

int count = 0;
for(int i = year1; i <= year2;i++){
if(isLeapYear(i)) count++;
}
return count;
}

/** Returns the value representing the day of the week for the first day of year,
Expand Down Expand Up @@ -52,5 +56,6 @@ private static int dayOfYear(int month, int day, int year)
public static int dayOfWeek(int month, int day, int year)
{
/* to be implemented in part (b) */
return firstDayofYear(year) + dayOfYear(month, day, year) % 7
}
}

0 comments on commit 9355f98

Please sign in to comment.