ReviewAnalysis free response 2

ReviewAnalysis free response problem from the 2022 AP Computer Science A Exam.

ReviewAnalysis is #3 from the from the 2022 AP Computer Science A Free Response problems.

https://apcentral.collegeboard.org/pdf/ap22-frq-computer-science-a.pdf?course=ap-computer-science-a

Part (a) – getAverageRating method

public double getAverageRating()
{
  int ratingSum = 0;
  
  for(Review rev : allReviews)
    ratingSum += rev.getRating();
  
  return ratingSum / (double) allReviews.length;
}

Part (b) – collectComments method

public ArrayList<String> collectComments()
{
  ArrayList<String> comments = new ArrayList<String>();
  
  for(int i = 0; i < allReviews.length; i++)
  {
    String com = allReviews[i].getComment();
    if(com.indexOf("!") >= 0)
    {
      String formatted = i + "-" + com;
      String lastChar = formatted.substring(formatted.length() - 1);
      if( ! lastChar.equals("!") && ! lastChar.equals("."))
        formatted += ".";
      
      comments.add(formatted);
    }
  }
  
  return comments;
}

2022 AP CS Exam Free Response Solutions

2 thoughts on “ReviewAnalysis free response

  1. Reply Jamie Liu May 6,2022 4:00 pm

    If I forgot to check for a period how many points will I lose?

    • Reply Brandon Horn May 6,2022 4:29 pm

      The College Board typically publishes their scoring guidelines later, along with their own canonical solutions.

Leave a Reply to Jamie Liu Cancel Reply