Skip to content

Commit

Permalink
Update APCalendar.java
Browse files Browse the repository at this point in the history
  • Loading branch information
dialtamirano authored May 4, 2024
1 parent b5337e1 commit 23b50f8
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/main/java/APCalendar.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@ 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 @@ -51,6 +56,7 @@ 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) */
int additionalDays = dayOfYear(month, day, year) - 1;
return (firstDayOfYear(year) + additionalDays) % 7;
}
}

0 comments on commit 23b50f8

Please sign in to comment.