Skip to content

Commit

Permalink
Update APCalendar.java
Browse files Browse the repository at this point in the history
  • Loading branch information
hahuang4 authored Apr 30, 2024
1 parent d306aa4 commit 6a5328f
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/main/java/APCalendar.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,15 @@ 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 y=year1;y<=year2;y++)
{
if(isLeapYear(y0)
{
count++;
}
}
return count;
}

/** Returns the value representing the day of the week for the first day of year,
Expand Down Expand Up @@ -52,5 +60,10 @@ 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 startDay=firstDayofYear(year);
int nthDay=dayofYear(month, day, year);
int returnDay= (startDay+nthDay-1)%7;
return returnDay;

}
}

0 comments on commit 6a5328f

Please sign in to comment.