ClubMembers free response 2

ClubMembers free response problem from the 2021 AP Computer Science A Exam.

ClubMembers is #3 from the from the 2021 AP Computer Science A Free Response problems.

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

Part (a) – addMembers method

public void addMembers(String[] names, int gradYear)
{
  for(String name : names)
    memberList.add(new MemberInfo(name, gradYear, true));
}

Part (b) – removeMembers method

public ArrayList<MemberInfo> removeMembers(int year)
{
  ArrayList<MemberInfo> goodStanding = new ArrayList<MemberInfo>();	

  int i = 0;
  while(i < memberList.size())
  {
    if(memberList.get(i).getGradYear() <= year)
    {
      MemberInfo removed = memberList.remove(i);
      if(removed.inGoodStanding())
        goodStanding.add(removed);
    }
    else
      i++;
  }
		
  return goodStanding;
}

2021 AP CS Exam Free Response Solutions

2 thoughts on “ClubMembers free response

  1. Reply Jacob Niestat May 9,2021 9:16 pm

    Hello, do you know how many points we would potentially lose if we failed to add the gradYear and the boolean parameter for part A? I have an example of what I mean below.

    public void addMembers(String[] names, int gradYear)
    {
    for(String name : names)
    memberList.add(new MemberInfo(name);
    }

    • Reply Brandon Horn May 12,2021 10:42 am

      My guess would be 1 point. You’ll have to wait until the scoring guidelines are released for an official answer.

Leave a Reply