FRQ 2019


1.a

public static int numberOfLeapYears(int year1, int year2) 
    {
        int count = 0; 
        for (int year = year1; year <= year2; y++) //for each year from year1 to year2
        { 
            if (isLeapYear(year)) //check if each year is a leap year
            { 
                count++; //increment count by 1 each time a year is a leap year
            }
        }
            return count; // otherwise return the value of count
    }


1.b

 public static int dayOfWeek(int month, int day, int year) 
 {
    int n = dayOfYear(month, day, year); //which day of the month for example the 10th day or the 5th day

    int firstDay = firstDayOfYear(year); //which day does the month start on for example tuesday would be 2 or thursday would be 4

    int whichDay = (firstDay + n - 1) % 7; // ex: firstday=4 n=10 whichDay would be equal to 6 which is Saturday. Divide by 7 to find the mod to find how many days after the first day to find whichDay

    return whichDay;
 }