Verityprep
Question Bank

AP® Computer Science A FRQ Practice: Free-Response Questions with Solutions

Work through AP Computer Science A free-response questions unit by unit, then check each answer against a worked solution.

Free · no sign-up Open questions need no account. Sign up or log in to open the rest.

Questions 141–150 of 329
  1. 141
  2. 142
  3. 143
  4. 144
  5. 145
  6. 146
  7. 147
  8. 148
  9. 149
  10. 150

Question 141

Free response Unit 2: Selection and Iteration

The ClubAttendance class stores the number of students who attended an after-school club on each recorded meeting day. The declaration below shows the instance variable and method headers.

public class ClubAttendance
{
    private int[] attendance;

    public ClubAttendance(int[] data)
    {
        attendance = data;
    }

    public int countBusyDays(int minStudents)
    { /* to be implemented in part (a) */ }

    public int firstLongRun(int minStudents, int runLength)
    { /* to be implemented in part (b) */ }
}

Part (a). Write the method countBusyDays, which returns the number of entries in attendance that are greater than or equal to minStudents.

For example, if attendance contains {12, 18, 16, 9, 18, 20}, then countBusyDays(18) returns 3.

Part (b). Write the method firstLongRun, which returns the starting index of the first sequence of runLength consecutive entries in attendance that are each greater than or equal to minStudents. If no such sequence exists, the method returns -1.

For example, if attendance contains {12, 18, 16, 19, 20, 10}, then firstLongRun(16, 3) returns 1 because the first run of three qualifying values begins at index 1. The run {18, 16, 19} qualifies, and no earlier run does.

The answer and the full solution open in a window.

Question 142

Free response Unit 2: Selection and Iteration
This problem involves calculating the total amount due for a restaurant bill, including tip and a possible service charge for large groups, then dividing among…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 143

Free response Unit 2: Selection and Iteration
This question involves library members who borrow and return books through a public library. A library tracks how many copies of each book are currently…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 144

Free response Unit 3: Class Creation

Sign up now. It's free!

This question is shown as an image. Sign up to see it with its answer and worked solution.

Question 145

Free response Unit 3: Class Creation
An ISBN (International Standard Book Number) is a numeric book identifier that is assigned to each published book. Prior to 2007, the ISBN numbers were 10…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 146

Free response Unit 3: Class Creation
This question involves methods that distribute text across lines of an electronic sign. The electronic sign and the text to be displayed on it are represented…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 147

Free response Unit 3: Class Creation
The class SingleTable represents a table at a restaurant. public class SingleTable { /** Returns the number of seats at this table. The value is always greater…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 148

Free response Unit 3: Class Creation
This question involves the implementation of a fitness tracking system that is represented by the StepTracker class. A StepTracker object is created with a…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 149

Free response Unit 3: Class Creation
This question involves the creation and use of a spinner to generate random numbers in a game. A GameSpinner object represents a spinner with a given number of…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 150

Free response Unit 3: Class Creation
Consider a guessing game in which a player tries to guess a hidden word. The hidden word contains only capital letters and has a length known to the player. A…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 141 of 329
Page 15 of 33