AP CSA FRQ Guide
2019 FRQ 1: APCalendar
Write two static calendar methods. The first counts leap years in an inclusive year range using a provided helper. The second computes the day-of-week code for a date using helper methods for the first day of the year and the day number within the year.
Skills Tested
What this FRQ is really practicing
Review these topics before attempting the problem.
Starter Approach
How to begin with your own plan
- 1Part A: loop from year1 through year2 inclusive.
- 2Use isLeapYear for each year and count the years that return true.
- 3Part B: use firstDayOfYear(year) and dayOfYear(month, day, year).
- 4Adjust for dayOfYear returning 1 for January 1, then return the result modulo 7.
Attempt the problem before opening the solution.
Common Mistakes
Mistakes to watch for while writing
Self Check
Review questions before you submit
Defines numberOfLeapYears as a public static int method with two int parameters.
Part A returns a count across an inclusive range.
Loops from year1 through year2 inclusive.
The final year must be checked, so use <= year2.
Uses isLeapYear for each candidate year.
The helper method is required for leap-year testing.
Increments and returns a leap-year count.
Count the years where isLeapYear returns true.
Defines dayOfWeek as a public static int method with month, day, and year parameters.
Part B returns a code from 0 through 6.
Calls firstDayOfYear with the year.
The first day of the year is the starting offset.
Calls dayOfYear with month, day, and year.
The helper returns the date position in the year.
Adjusts for dayOfYear being one-based.
January 1 should add zero days to firstDayOfYear.
Practice Links
