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;
}
If I forgot to check for a period how many points will I lose?
The College Board typically publishes their scoring guidelines later, along with their own canonical solutions.