Status: Started
  • APCalendar.java
Font Size
14
Parentheses autocomplete
Wrap lines
Editor
Theme
Code with blocks by default
Console Font Size
12
Console Theme
Display Server Graphics Screen
Show File Tab Bar
Debug Mode
2 Calendar Part a (text only)
APCalendar.java
/** Returns the number of leap years between year1 and year2, inclusive.
* Precondition: 0 <= year1 <= year2
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Output
Docs
Exercise
More
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
This student is viewing this assignment in English. View this page in English?

5 points

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.

}


Part 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.

  1. isLeapYear(year) returns true if year is a leap year and false otherwise. 

Complete method numberOfLeapYears. You must use isLeapYear appropriately to receive full credit. 


Reset Code

Slides and Notes

No slides available for this video

About

Java (main)
Java Version 1.8.0_222