AP CSA FRQ Guide

2022 FRQ 3: ReviewAnalysis

Write two methods for analyzing website reviews. The first computes the average rating from an array of Review objects. The second collects comments containing exclamation points, prefixes each with its index, and ensures the formatted comment ends with punctuation.

Arrays, ArrayList, and String Formatting22 minute targetarraysArrayListString methodstraversalformatting

Skills Tested

What this FRQ is really practicing

arraysArrayListString methodstraversalformatting

Treat these skills as the study checklist. If any tag feels shaky, review that topic before attempting the full written response.

Starter Approach

How to begin without copying a solution

  1. 1Part A: traverse allReviews, add each Review rating, and return the average as a double.
  2. 2Part B: create a new ArrayList<String> for formatted comments.
  3. 3Include only comments that contain an exclamation point.
  4. 4Prefix each selected comment with its array index and a hyphen.
  5. 5If the original selected comment does not end with a period or exclamation point, add a period.

Write a first attempt before revealing any solution outline. Most AP CSA FRQ progress comes from tracing your own code and finding the missing case.

Common Mistakes

Mistakes to watch for while writing

Computing the average with integer division.
Including every nonempty comment instead of only comments containing an exclamation point.
Prefixing comments with a 1-based position instead of the array index.
Adding a period even when the comment already ends with an exclamation point.
Changing Review objects or allReviews even though the method should only collect formatted copies.

Self Check

Review questions before you submit

Defines getAverageRating with double return type and no parameters.

Part A returns an arithmetic mean.

Traverses the allReviews array.

Use allReviews.length or an enhanced for loop.

Uses getRating for each review.

Ratings are accessed through the Review method.

Returns a double average rather than integer division.

Cast the sum or divisor to double.

Defines collectComments with ArrayList<String> return type.

Part B returns a list of formatted strings.

Creates a new ArrayList<String> result.

Do not modify allReviews.

Uses an index-based traversal for formatted prefixes.

The returned String begins with the review index.

Uses getComment to access each comment.

Comments are accessed through the Review method.

Practice Links

Where to go next