2019 AP® COMPUTER SCIENCE A FREE-RESPONSE QUESTIONS 1. The APCalendar class contains methods used to calculate information about a calendar. You will write two methods of the class. public class APCalendar { /** Returns true if year is a leap year and false otherwise. */ private static boolean isLeapYear(int year) { /* implementation not shown */ } /** Returns the number of leap years between year1 and year2, inclusive. * Precondition: 0 <= year1 <= year2 */ public static int numberOfLeapYears(int year1, int year2) { /* to be implemented in part (a) */ } /** Returns the value representing the day of the week for the first day of year, * where 0 denotes Sunday, 1 denotes Monday, ..., and 6 denotes Saturday. */ private static int firstDayOfYear(int year) { /* implementation not shown */ } /** Returns n, where month, day, and year specify the nth day of the year. * Returns 1 for January 1 (month = 1, day = 1) of any year. * Precondition: The date represented by month, day, year is a valid date. */ private static int dayOfYear(int month, int day, int year) { /* implementation not shown */ } /** Returns the value representing the day of the week for the given date * (month, day, year), where 0 denotes Sunday, 1 denotes Monday, ..., * and 6 denotes Saturday. * Precondition: The date represented by month, day, year is a valid date. */ public static int dayOfWeek(int month, int day, int year) { /* to be implemented in part (b) */ } // There may be instance variables, constructors, and other methods not shown. }   (a) Write the static method numberOfLeapYears, which returns the number of leap years between year1 and year2, inclusive. In order to calculate this value, a helper method is provided for you. • isLeapYear(year) returns true if year is a leap year and false otherwise. Complete method numberOfLeapYears below. You must use isLeapYear appropriately to receive full credit. /** Returns the number of leap years between year1 and year2, inclusive. * Precondition: 0 <= year1 <= year2 */ public static int numberOfLeapYears(int year1, int year

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Question

2019 AP® COMPUTER SCIENCE A FREE-RESPONSE QUESTIONS
1. The APCalendar class contains methods used to calculate information about a calendar. You will write two methods of the class.
public class APCalendar
{
/** Returns true if year is a leap year and false otherwise. */ private static boolean isLeapYear(int year)
{ /* implementation not shown */ }
/** Returns the number of leap years between year1 and year2, inclusive. * Precondition: 0 <= year1 <= year2
*/
public static int numberOfLeapYears(int year1, int year2)
{ /* to be implemented in part (a) */ }
/** Returns the value representing the day of the week for the first day of year, * where 0 denotes Sunday, 1 denotes Monday, ..., and 6 denotes Saturday. */
private static int firstDayOfYear(int year)
{ /* implementation not shown */ }
/** Returns n, where month, day, and year specify the nth day of the year.
* Returns 1 for January 1 (month = 1, day = 1) of any year.
* Precondition: The date represented by month, day, year is a valid date. */
private static int dayOfYear(int month, int day, int year)
{ /* implementation not shown */ }
/** Returns the value representing the day of the week for the given date
* (month, day, year), where 0 denotes Sunday, 1 denotes Monday, ...,
* and 6 denotes Saturday.
* Precondition: The date represented by month, day, year is a valid date. */
public static int dayOfWeek(int month, int day, int year)
{ /* to be implemented in part (b) */ }
// There may be instance variables, constructors, and other methods not shown. }

 

(a) Write the static method numberOfLeapYears, which returns the number of leap years between year1 and year2, inclusive.
In order to calculate this value, a helper method is provided for you.
• isLeapYear(year) returns true if year is a leap year and false otherwise.
Complete method numberOfLeapYears below. You must use isLeapYear appropriately to receive full credit.
/** Returns the number of leap years between year1 and year2, inclusive. * Precondition: 0 <= year1 <= year2
*/
public static int numberOfLeapYears(int year1, int year2)

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Data members
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education