Skip to content

Commit

Permalink
Update APCalendar.java
Browse files Browse the repository at this point in the history
  • Loading branch information
AdenChiu22 authored May 28, 2024
1 parent 7374e85 commit e45f579
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/main/java/APCalendar.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,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) == true)
count ++;
for(int i = year1; i <= year2; i++)
if(isLeapYear(i))
count++;
return count;

}
Expand Down Expand Up @@ -55,8 +56,7 @@ private static int dayOfYear(int month, int day, int year)
*/
public static int dayOfWeek(int month, int day, int year)
{
int firstDay = firstDayOfYear(year);
int doy = dayOfYear(month, day, year);
return (firstDay + doy - 1) % 7;
int additionalDays = dayOfYear(month, day, year) - 1;
return (firstDayOfYear(year) + additionalDays) % 7;
}
}

0 comments on commit e45f579

Please sign in to comment.