• 咨询电话 13023111482
  • 犀牛首页
  • IB课程
  • AP课程
  • G5笔面试
  • AMC竞赛
  • HMMT竞赛
  • 物理碗竞赛
犀牛教育
  • AP力学真题
  • AP物理1真题
  • AP物理2真题
  • AP计算机真题
  • AP生物真题
  • AP化学真题
  • AP电磁学真题

AP计算机真题

首页 > AP > AP计算机 > AP计算机真题

2019年AP计算机简答题真题PDF下载

2021-08-10

2019年AP计算机简答题真题PDF下载

 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)

 

(b) Write the static method dayOfWeek, which returns the integer 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. For example, 2019 began on a Tuesday, and January 5 is the fifth day of 2019. As a result, January 5, 2019, fell on a Saturday, and the method call dayOfWeek(1, 5, 2019) returns 6.

As another example, January 10 is the tenth day of 2019. As a result, January 10, 2019, fell on a Thursday, and the method call dayOfWeek(1, 10, 2019) returns 4.

In order to calculate this value, two helper methods are provided for you.

firstDayOfYear(year) returns the integer value representing the day of the week for the first day of year, where 0 denotes Sunday, 1 denotes Monday, ..., and 6 denotes Saturday. For example, since 2019 began on a Tuesday, firstDayOfYear(2019) returns 2. 

dayOfYear(month, day, year) returns n, where month, day, and year specify the nth day of the year. For the first day of the year, January 1 (month = 1, day = 1), the value 1 is returned. This method accounts for whether year is a leap year. For example,

dayOfYear(3, 1, 2017) returns 60, since 2017 is not a leap year, while

dayOfYear(3, 1, 2016) returns 61, since 2016 is a leap year.

Complete method dayOfWeek below. You must use firstDayOfYear and dayOfYear appropriately to receive full credit.

/** 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) 

2019年AP计算机简答题真题省略!


你可能还关注

  1. 2021年AP计算机简答题真题PDF下载 2021-08-10   
    2021年AP计算机简答题真题PDF下载
    详情阅读
  2. 2018年AP计算机简答题真题PDF下载 2021-08-10   
    2018年AP计算机简答题真题PDF下载
    详情阅读
  3. 2017年AP计算机简答题真题PDF下载 2021-08-10   
    2017年AP计算机简答题真题PDF下载
    详情阅读
  4. 2016年AP计算机简答题真题PDF下载 2021-08-10   
    2016年AP计算机简答题真题PDF下载
    详情阅读
  5. 2015年AP计算机简答题真题PDF下载 2021-08-10   
    2015年AP计算机简答题真题PDF下载
    详情阅读

扫码免费下载真题

AP计算机真题

  • 2021年AP计算机简答题真题PDF下载
  • 2019年AP计算机简答题真题PDF下载
  • 2018年AP计算机简答题真题PDF下载
  • 2017年AP计算机简答题真题PDF下载
  • 2016年AP计算机简答题真题PDF下载
  • 2015年AP计算机简答题真题PDF下载
犀牛国际

犀牛国际(X-NEW),由业内多名教学专家共同组建,不乏来自加州理工大学、剑桥大学、清华大学、北京大学、复旦大学、新加坡国立大学等国际一流大学。 其中有博士、硕士的学历老师众多,学术功底扎实,有的已经执教十余年,国际领域经验丰富。

国际学科

  • IB课程辅导
  • AP课程培训
  • A-Level课程培训
  • IGCSE课程辅导

国际竞赛

  • AMC数学竞赛
  • AIME数学竞赛
  • HiMCM竞赛
  • PUMaC竞赛
  • HMMT竞赛
  • 滑铁卢数学竞赛
  • 物理碗竞赛
  • BPhO竞赛
  • BAAO竞赛
  • USNCO竞赛
  • UKCHO竞赛
  • CCC竞赛
  • USABO竞赛
  • BBO竞赛
  • BRAIN BEE

G5笔面试

  • STEP
  • PAT
  • ECAA
  • LNAT
  • MAT
  • TSA
  • NSAA
  • BMAT
  • ENGAA
  • CTMUA
犀牛国际 版权所有 沪ICP备2021004381号-1