Ap Csa 2022 Frq 3 Reviewanalysis
AP CSA 2022 FRQ 3: ReviewAnalysis
Complete solution, scoring rubric, and walkthrough — verified from the official College Board PDF
| Question Type | ArrayList |
| Skills Tested | Array traversal, indexed loop, String methods (contains, charAt), double division |
| Difficulty | Medium |
| Recommended Time | 22 minutes |
What This Problem Asks
2022 AP CSA FRQ 3 ReviewAnalysis asks students to write two methods that analyze an array of Review objects. getAverageRating computes the arithmetic mean of all ratings as a double. collectComments collects comments containing exclamation points, formats each as index-comment, and appends a period if the comment doesn’t already end in . or !.
What This FRQ Tests
This FRQ tests Unit 4 (array traversal, ArrayList building) and Unit 1 String methods (contains, charAt, length).
Official Question & PDF
PDF cannot display on this device. Open PDF directly →
Provided Code
public class Review
{
private int rating;
private String comment;
public Review(int r, String c) {
rating = r; comment = c;
}
public int getRating() {
return rating;
}
public String getComment() {
return comment;
}
}
public class ReviewAnalysis
{
private Review[] allReviews; // array, not ArrayList
public ReviewAnalysis() { /* not shown */ }
public double getAverageRating() { /* to be implemented in part (a) */ }
public ArrayList collectComments() { /* to be implemented in part (b) */ }
}
Part A — 4 Points
Write getAverageRating, which returns the average rating of all elements in allReviews as a double.
Write Your Solution
Scoring Rubric (Part A — 4 points)
| +1 | Traverses allReviews array with no bounds errors |
| +1 | Calls getRating on a Review object |
| +1 | Accumulates a sum of ratings |
| +1 | Returns correct double average (divides by length, not integer division) |
Solution
public double getAverageRating()
{
double sum = 0;
for (Review r : allReviews)
{
sum += r.getRating();
}
return sum / allReviews.length;
}
int sum and divide sum / allReviews.length, Java performs integer division (truncates). Declaring double sum forces a double result. Alternatively, cast: (double) sum / allReviews.length.Part B — 5 Points
Write collectComments, which returns an ArrayList of formatted comments that contain "!". Each string is formatted as index + "-" + comment. If comment doesn’t end in . or !, append a period.
Write Your Solution
Scoring Rubric (Part B — 5 points)
| +1 | Traverses allReviews with index (for-each does not give index) |
| +1 | Calls getComment on a Review object and checks for "!"
|
| +1 | Correctly formats the string: index + "-" + comment |
| +1 | Appends a period if comment does not end in "." or "!"
|
| +1 | Returns correct ArrayList with only exclamation-containing comments (algorithm) |
Solution
public ArrayListcollectComments() { ArrayList result = new ArrayList (); for (int i = 0; i < allReviews.length; i++) { String comment = allReviews[i].getComment(); if (comment.contains("!")) { String formatted = i + "-" + comment; char last = comment.charAt(comment.length() - 1); if (last != '.' && last != '!') { formatted += "."; } result.add(formatted); } } return result; }
i to prepend to the string. An enhanced for loop doesn’t give you the index, so you can’t use it here.Common Mistakes to Avoid
The formatted string must begin with the index of the review. An enhanced for loop does not provide the index.
Wrong
for (Review r : allReviews) {
// no way to get the index 'i' here
}
Correct
for (int i = 0; i < allReviews.length; i++) {
String comment = allReviews[i].getComment();
if (comment.contains("!")) {
String formatted = i + "-" + comment;
...
}
}
If both numerator and denominator are ints, Java does integer division and truncates the decimal.
Wrong
int sum = 0; ... return sum / allReviews.length; // truncates decimal!
Correct
double sum = 0; // or cast: (double) sum / allReviews.length ... return sum / allReviews.length;
Exam Tips
Review[]), not an ArrayList. Use array length (allReviews.length) and array access (allReviews[i]).i + "-" + comment then optionally append ".".'.' or '!'. Check comment.charAt(comment.length()-1).Scoring Summary
| Part | Method | Points |
|---|---|---|
| Part A | Write |
4 |
| Part B | Write |
5 |
| Total | 9 |
Want the Complete 2022 FRQ Solutions?
Browse all past AP CSA FRQs with full solutions and scoring breakdowns.
Related FRQs
ArrayList 2021 FRQ 3: ClubMembers — ArrayList add and backward removal ArrayList 2023 FRQ 3: WeatherData — ArrayList cleaning and heat wave detectionStudy the Concepts
Unit 4 Study Guide → Unit 1 Study Guide →
Struggling with FRQs? Get 1-on-1 Help
Work directly with Tanner — AP CS teacher with 11+ years experience and 1,845+ verified tutoring hours. 54.5% of students score 5s (vs. 25.5% national average).
5-session packages at $125/hr. Venmo, Zelle, PayPal, or credit card.
Frequently Asked Questions
What does 2022 AP CSA FRQ 3 ReviewAnalysis test?
FRQ 3 tests traversal of a Review array. getAverageRating accumulates a double sum. collectComments requires an indexed loop (to get the review's position), contains() to filter by exclamation point, and conditional string appending.
How many points is 2022 AP CSA FRQ 3 worth?
9 points: 4 for Part A (getAverageRating) and 5 for Part B (collectComments).
Why can't I use an enhanced for loop in collectComments?
You need the index of each review to prepend it to the formatted string. Enhanced for loops don't give you the index.
How do I check if a comment ends in a period or exclamation point?
Use comment.charAt(comment.length() - 1) and compare it to '.' and '!'. If neither, append a period to the formatted string.
Get in Touch
Whether you're a student, parent, or teacher — I'd love to hear from you.
Just want free AP CS resources?
Enter your email below and check the subscribe box — no message needed. Students get daily practice questions and study tips. Teachers get curriculum resources and teaching strategies.
Message Sent!
Thanks for reaching out. I'll get back to you within 24 hours.
Prefer email? Reach me directly at [email protected]