<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Review for AP Comp Sci Exam</title>
	<atom:link href="https://apcomputersciencetutoring.com/exam-review/feed/" rel="self" type="application/rss+xml" />
	<link>https://apcomputersciencetutoring.com/exam-review</link>
	<description></description>
	<lastBuildDate>Fri, 06 May 2022 20:41:33 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.1.1</generator>
	<item>
		<title>Data free response</title>
		<link>https://apcomputersciencetutoring.com/exam-review/data-free-response/</link>
					<comments>https://apcomputersciencetutoring.com/exam-review/data-free-response/#respond</comments>
		
		<dc:creator><![CDATA[Brandon Horn]]></dc:creator>
		<pubDate>Fri, 06 May 2022 20:07:47 +0000</pubDate>
				<category><![CDATA[2022 AP Computer Science Exam Answers]]></category>
		<guid isPermaLink="false">https://apcomputersciencetutoring.com/exam-review/?p=3428</guid>

					<description><![CDATA[<p>Data free response problem from the 2022 AP Computer Science A Exam. Data is #4 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) &#8211; repopulate method public void repopulate() { for(int r = 0; r &#60; grid.length; r++) { for(int c = 0; c &#60; grid[0].length; c++) { ...<a class="post-readmore" href="https://apcomputersciencetutoring.com/exam-review/data-free-response/">read more</a></p>
The post <a href="https://apcomputersciencetutoring.com/exam-review/data-free-response/">Data free response</a> first appeared on <a href="https://apcomputersciencetutoring.com/exam-review">Review for AP Comp Sci Exam</a>.]]></description>
										<content:encoded><![CDATA[<p><span class="ctext">Data</span> free response problem from the 2022 AP Computer Science A Exam.</p>
<p><span id="more-3428"></span></p>
<p>Data is #4 from the from the 2022 AP Computer Science A Free Response problems.</p>
<p><a href="https://apcentral.collegeboard.org/pdf/ap22-frq-computer-science-a.pdf?course=ap-computer-science-a">https://apcentral.collegeboard.org/pdf/ap22-frq-computer-science-a.pdf?course=ap-computer-science-a</a></p>
<h2>Part (a) &#8211; <span class="ctext">repopulate</span> method</h2>
<pre><span class="highlight">public void repopulate()</span>
{
  for(int r = 0; r &lt; grid.length; r++)
  {
    for(int c = 0; c &lt; grid[0].length; c++)
    {
      int rand = (int) (Math.random() * MAX) + 1;
      while(rand % 10 != 0 || rand % 100 == 0)
        rand = (int) (Math.random() * MAX) + 1;
      
      grid[r][c] = rand;
    }
  }
}
</pre>
<h2>Part (b) &#8211; <span class="ctext">countIncreasingCols</span> method</h2>
<pre><span class="highlight">public int countIncreasingCols()</span>
{
  int increasingCols = 0;
  
  for(int c = 0; c &lt; grid[0].length; c++)
  {
    boolean isIncreasing = true;
    
    for(int r = 1; r &lt; grid.length; r++)
      if(grid[r-1][c] &gt; grid[r][c])
        isIncreasing = false;
    
    if(isIncreasing)
      increasingCols++;
  }
  
  return increasingCols;
}
</pre>
<h3>2022 AP CS Exam Free Response Solutions</h3>
<ul>
<li><a href="https://apcomputersciencetutoring.com/exam-review/game-free-response/">Game Free Response Solution</a></li>
<li><a href="https://apcomputersciencetutoring.com/exam-review/textbook-free-response/">Textbook Free Response Solution</a></li>
<li><a href="https://apcomputersciencetutoring.com/exam-review/reviewanalysis-free-response/">ReviewAnalysis Free Response Solution</a></li>
</ul>The post <a href="https://apcomputersciencetutoring.com/exam-review/data-free-response/">Data free response</a> first appeared on <a href="https://apcomputersciencetutoring.com/exam-review">Review for AP Comp Sci Exam</a>.]]></content:encoded>
					
					<wfw:commentRss>https://apcomputersciencetutoring.com/exam-review/data-free-response/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>ReviewAnalysis free response</title>
		<link>https://apcomputersciencetutoring.com/exam-review/reviewanalysis-free-response/</link>
					<comments>https://apcomputersciencetutoring.com/exam-review/reviewanalysis-free-response/#comments</comments>
		
		<dc:creator><![CDATA[Brandon Horn]]></dc:creator>
		<pubDate>Fri, 06 May 2022 19:56:19 +0000</pubDate>
				<category><![CDATA[2022 AP Computer Science Exam Answers]]></category>
		<guid isPermaLink="false">https://apcomputersciencetutoring.com/exam-review/?p=3430</guid>

					<description><![CDATA[<p>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) &#8211; getAverageRating method public double getAverageRating() { int ratingSum = 0; for(Review rev : allReviews) ratingSum += rev.getRating(); return ratingSum / (double) allReviews.length; } Part ...<a class="post-readmore" href="https://apcomputersciencetutoring.com/exam-review/reviewanalysis-free-response/">read more</a></p>
The post <a href="https://apcomputersciencetutoring.com/exam-review/reviewanalysis-free-response/">ReviewAnalysis free response</a> first appeared on <a href="https://apcomputersciencetutoring.com/exam-review">Review for AP Comp Sci Exam</a>.]]></description>
										<content:encoded><![CDATA[<p><span class="ctext">ReviewAnalysis</span> free response problem from the 2022 AP Computer Science A Exam.</p>
<p><span id="more-3430"></span></p>
<p>ReviewAnalysis is #3 from the from the 2022 AP Computer Science A Free Response problems.</p>
<p><a href="https://apcentral.collegeboard.org/pdf/ap22-frq-computer-science-a.pdf?course=ap-computer-science-a">https://apcentral.collegeboard.org/pdf/ap22-frq-computer-science-a.pdf?course=ap-computer-science-a</a></p>
<h2>Part (a) &#8211; <span class="ctext">getAverageRating</span> method</h2>
<pre><span class="highlight">public double getAverageRating()</span>
{
  int ratingSum = 0;
  
  for(Review rev : allReviews)
    ratingSum += rev.getRating();
  
  return ratingSum / (double) allReviews.length;
}
</pre>
<h2>Part (b) &#8211; <span class="ctext">collectComments</span> method</h2>
<pre><span class="highlight">public ArrayList&lt;String&gt; collectComments()</span>
{
  ArrayList&lt;String&gt; comments = new ArrayList&lt;String&gt;();
  
  for(int i = 0; i &lt; allReviews.length; i++)
  {
    String com = allReviews[i].getComment();
    if(com.indexOf("!") &gt;= 0)
    {
      String formatted = i + "-" + com;
      String lastChar = formatted.substring(formatted.length() - 1);
      if( ! lastChar.equals("!") &amp;&amp; ! lastChar.equals("."))
        formatted += ".";
      
      comments.add(formatted);
    }
  }
  
  return comments;
}
</pre>
<h3>2022 AP CS Exam Free Response Solutions</h3>
<ul>
<li><a href="https://apcomputersciencetutoring.com/exam-review/game-free-response/">Game Free Response Solution</a></li>
<li><a href="https://apcomputersciencetutoring.com/exam-review/textbook-free-response/">Textbook Free Response Solution</a></li>
<li><a href="https://apcomputersciencetutoring.com/exam-review/data-free-response/">Data Free Response Solution</a></li>
</ul>The post <a href="https://apcomputersciencetutoring.com/exam-review/reviewanalysis-free-response/">ReviewAnalysis free response</a> first appeared on <a href="https://apcomputersciencetutoring.com/exam-review">Review for AP Comp Sci Exam</a>.]]></content:encoded>
					
					<wfw:commentRss>https://apcomputersciencetutoring.com/exam-review/reviewanalysis-free-response/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>Textbook free response</title>
		<link>https://apcomputersciencetutoring.com/exam-review/textbook-free-response/</link>
					<comments>https://apcomputersciencetutoring.com/exam-review/textbook-free-response/#respond</comments>
		
		<dc:creator><![CDATA[Brandon Horn]]></dc:creator>
		<pubDate>Fri, 06 May 2022 19:43:22 +0000</pubDate>
				<category><![CDATA[2022 AP Computer Science Exam Answers]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<guid isPermaLink="false">https://apcomputersciencetutoring.com/exam-review/?p=3432</guid>

					<description><![CDATA[<p>Textbook free response problem from the 2022 AP Computer Science A Exam. Textbook is #2 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 Textbook class public class Textbook extends Book { private int edition; public Textbook(String bookTitle, double bookPrice, int edition) { super(bookTitle, bookPrice); this.edition = edition; } public int ...<a class="post-readmore" href="https://apcomputersciencetutoring.com/exam-review/textbook-free-response/">read more</a></p>
The post <a href="https://apcomputersciencetutoring.com/exam-review/textbook-free-response/">Textbook free response</a> first appeared on <a href="https://apcomputersciencetutoring.com/exam-review">Review for AP Comp Sci Exam</a>.]]></description>
										<content:encoded><![CDATA[<p><span class="ctext">Textbook</span> free response problem from the 2022 AP Computer Science A Exam.</p>
<p><span id="more-3432"></span></p>
<p>Textbook is #2 from the from the 2022 AP Computer Science A Free Response problems.</p>
<p><a href="https://apcentral.collegeboard.org/pdf/ap22-frq-computer-science-a.pdf?course=ap-computer-science-a">https://apcentral.collegeboard.org/pdf/ap22-frq-computer-science-a.pdf?course=ap-computer-science-a</a></p>
<h2><span class="ctext">Textbook</span> class</h2>
<pre>public class Textbook extends Book
{
  <span class="highlight">private int edition;</span>

  <span class="highlight">public Textbook(String bookTitle, double bookPrice, int edition)</span>
  {
    super(bookTitle, bookPrice);
    this.edition = edition;
  }

  <span class="highlight">public int getEdition()</span>
  {
    return edition;
  }

  <span class="highlight">public String getBookInfo()</span>
  {
    return super.getBookInfo() + "-" + edition;
  }

  <span class="highlight">public boolean canSubstituteFor(Textbook otherTextbook)</span>
  {
    return this.getTitle().equals(otherTextbook.getTitle()) &amp;&amp;
        this.getEdition() &gt;= otherTextbook.getEdition();
  }
}
</pre>
<h3>2022 AP CS Exam Free Response Solutions</h3>
<ul>
<li><a href="https://apcomputersciencetutoring.com/exam-review/game-free-response/">Game Free Response Solution</a></li>
<li><a href="https://apcomputersciencetutoring.com/exam-review/reviewanalysis-free-response/">ReviewAnalysis Free Response Solution</a></li>
<li><a href="https://apcomputersciencetutoring.com/exam-review/data-free-response/">Data Free Response Solution</a></li>
</ul>The post <a href="https://apcomputersciencetutoring.com/exam-review/textbook-free-response/">Textbook free response</a> first appeared on <a href="https://apcomputersciencetutoring.com/exam-review">Review for AP Comp Sci Exam</a>.]]></content:encoded>
					
					<wfw:commentRss>https://apcomputersciencetutoring.com/exam-review/textbook-free-response/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Game free response</title>
		<link>https://apcomputersciencetutoring.com/exam-review/game-free-response/</link>
					<comments>https://apcomputersciencetutoring.com/exam-review/game-free-response/#respond</comments>
		
		<dc:creator><![CDATA[Brandon Horn]]></dc:creator>
		<pubDate>Fri, 06 May 2022 19:35:32 +0000</pubDate>
				<category><![CDATA[2022 AP Computer Science Exam Answers]]></category>
		<guid isPermaLink="false">https://apcomputersciencetutoring.com/exam-review/?p=3434</guid>

					<description><![CDATA[<p>Game free response problem from the 2022 AP Computer Science A Exam. Game is #1 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) &#8211; getScore method public int getScore() { int score = 0; if(levelOne.goalReached()) { score += levelOne.getPoints(); if(levelTwo.goalReached()) { score += levelTwo.getPoints(); if(levelThree.goalReached()) { score += ...<a class="post-readmore" href="https://apcomputersciencetutoring.com/exam-review/game-free-response/">read more</a></p>
The post <a href="https://apcomputersciencetutoring.com/exam-review/game-free-response/">Game free response</a> first appeared on <a href="https://apcomputersciencetutoring.com/exam-review">Review for AP Comp Sci Exam</a>.]]></description>
										<content:encoded><![CDATA[<p><span class="ctext">Game</span> free response problem from the 2022 AP Computer Science A Exam.</p>
<p><span id="more-3434"></span></p>
<p>Game is #1 from the from the 2022 AP Computer Science A Free Response problems.</p>
<p><a href="https://apcentral.collegeboard.org/pdf/ap22-frq-computer-science-a.pdf?course=ap-computer-science-a">https://apcentral.collegeboard.org/pdf/ap22-frq-computer-science-a.pdf?course=ap-computer-science-a</a></p>
<h2>Part (a) &#8211; <span class="ctext">getScore</span> method</h2>
<pre><span class="highlight">public int getScore()</span>
{
  int score = 0;
  
  if(levelOne.goalReached())
  {
    score += levelOne.getPoints();
    
    if(levelTwo.goalReached())
    {
      score += levelTwo.getPoints();
      
      if(levelThree.goalReached())
      {
        score += levelThree.getPoints();
      }
    }
  }
  
  if(isBonus())
    score *= 3;
  
  return score;
}
</pre>
<h2>Part (b) &#8211; <span class="ctext">playManyTimes</span> method</h2>
<pre><span class="highlight">public int playManyTimes(int num)</span>
{
  play();
  int bestScore = getScore();
  
  for(int g = 2; g &lt;= num; g++)
  {
    play();
    int score = getScore();
    if(score &gt; bestScore)
      bestScore = score;
  }
  
  return bestScore;
}
</pre>
<h3>2022 AP CS Exam Free Response Solutions</h3>
<ul>
<li><a href="https://apcomputersciencetutoring.com/exam-review/textbook-free-response/">Textbook Free Response Solution</a></li>
<li><a href="https://apcomputersciencetutoring.com/exam-review/reviewanalysis-free-response/">ReviewAnalysis Free Response Solution</a></li>
<li><a href="https://apcomputersciencetutoring.com/exam-review/data-free-response/">Data Free Response Solution</a></li>
</ul>The post <a href="https://apcomputersciencetutoring.com/exam-review/game-free-response/">Game free response</a> first appeared on <a href="https://apcomputersciencetutoring.com/exam-review">Review for AP Comp Sci Exam</a>.]]></content:encoded>
					
					<wfw:commentRss>https://apcomputersciencetutoring.com/exam-review/game-free-response/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>WordMatch free response</title>
		<link>https://apcomputersciencetutoring.com/exam-review/wordmatch-free-response/</link>
					<comments>https://apcomputersciencetutoring.com/exam-review/wordmatch-free-response/#comments</comments>
		
		<dc:creator><![CDATA[Brandon Horn]]></dc:creator>
		<pubDate>Sat, 08 May 2021 19:05:49 +0000</pubDate>
				<category><![CDATA[2021 AP Computer Science Exam Answers]]></category>
		<guid isPermaLink="false">https://apcomputersciencetutoring.com/exam-review/?p=3352</guid>

					<description><![CDATA[<p>WordMatch free response problem from the 2021 AP Computer Science A Exam. WordMatch is #1 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) &#8211; scoreGuess method public int scoreGuess(String guess) { int count = 0; for(int i = 0; i &#60; secret.length(); i++) { int j = i ...<a class="post-readmore" href="https://apcomputersciencetutoring.com/exam-review/wordmatch-free-response/">read more</a></p>
The post <a href="https://apcomputersciencetutoring.com/exam-review/wordmatch-free-response/">WordMatch free response</a> first appeared on <a href="https://apcomputersciencetutoring.com/exam-review">Review for AP Comp Sci Exam</a>.]]></description>
										<content:encoded><![CDATA[<p><span class="ctext">WordMatch</span> free response problem from the 2021 AP Computer Science A Exam.</p>
<p><span id="more-3352"></span></p>
<p>WordMatch is #1 from the from the 2021 AP Computer Science A Free Response problems.</p>
<p><a href="https://apcentral.collegeboard.org/pdf/ap21-frq-computer-science-a.pdf?course=ap-computer-science-a">https://apcentral.collegeboard.org/pdf/ap21-frq-computer-science-a.pdf?course=ap-computer-science-a</a></p>
<h2>Part (a) &#8211; <span class="ctext">scoreGuess</span> method</h2>
<pre><span class="highlight">public int scoreGuess(String guess)</span>
{
  int count = 0;

  for(int i = 0; i &lt; secret.length(); i++)
  {
    int j = i + guess.length();

    if(j &lt;= secret.length() &amp;&amp; secret.substring(i, j).equals(guess))
      count++;
  }

  return count * (guess.length() * guess.length());
}
</pre>
<p>I would normally have used <span class="ctext">indexOf</span> for this problem; however, the description mentioned that the occurrences of <span class="ctext">guess</span> might overlap (and the second example showed such a situation). This approach seemed more reliable to me.</p>
<h2>Part (b) &#8211; <span class="ctext">findBetterGuess</span> method</h2>
<pre><span class="highlight">public String findBetterGuess(String guess1, String guess2)</span>
{
  int score1 = scoreGuess(guess1);
  int score2 = scoreGuess(guess2);
  
  if(score1 &gt; score2)
    return guess1;
  else if(score2 &gt; score1)
    return guess2;
  else
  {
    if(guess1.compareTo(guess2) &gt; 0)
      return guess1;
    else
      return guess2;
  }
}
</pre>
<h3>2021 AP CS Exam Free Response Solutions</h3>
<ul>
<li><a href="https://apcomputersciencetutoring.com/exam-review/combinedtable-free-response/">CombinedTable Free Response Solution</a></li>
<li><a href="https://apcomputersciencetutoring.com/exam-review/clubmembers-free-response/">ClubMembers Free Response Solution</a></li>
<li><a href="https://apcomputersciencetutoring.com/exam-review/arrayresizer-free-response/">ArrayResizer Free Response Solution</a></li>
</ul>The post <a href="https://apcomputersciencetutoring.com/exam-review/wordmatch-free-response/">WordMatch free response</a> first appeared on <a href="https://apcomputersciencetutoring.com/exam-review">Review for AP Comp Sci Exam</a>.]]></content:encoded>
					
					<wfw:commentRss>https://apcomputersciencetutoring.com/exam-review/wordmatch-free-response/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>CombinedTable free response</title>
		<link>https://apcomputersciencetutoring.com/exam-review/combinedtable-free-response/</link>
					<comments>https://apcomputersciencetutoring.com/exam-review/combinedtable-free-response/#comments</comments>
		
		<dc:creator><![CDATA[Brandon Horn]]></dc:creator>
		<pubDate>Sat, 08 May 2021 19:02:21 +0000</pubDate>
				<category><![CDATA[2021 AP Computer Science Exam Answers]]></category>
		<guid isPermaLink="false">https://apcomputersciencetutoring.com/exam-review/?p=3349</guid>

					<description><![CDATA[<p>CombinedTable free response problem from the 2021 AP Computer Science A Exam. CombinedTable is #2 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) &#8211; CombinedTable class public class CombinedTable { private SingleTable t1, t2; public CombinedTable(SingleTable t1, SingleTable t2) { this.t1 = t1; this.t2 = t2; } public ...<a class="post-readmore" href="https://apcomputersciencetutoring.com/exam-review/combinedtable-free-response/">read more</a></p>
The post <a href="https://apcomputersciencetutoring.com/exam-review/combinedtable-free-response/">CombinedTable free response</a> first appeared on <a href="https://apcomputersciencetutoring.com/exam-review">Review for AP Comp Sci Exam</a>.]]></description>
										<content:encoded><![CDATA[<p><span class="ctext">CombinedTable</span> free response problem from the 2021 AP Computer Science A Exam.</p>
<p><span id="more-3349"></span></p>
<p>CombinedTable is #2 from the from the 2021 AP Computer Science A Free Response problems.</p>
<p><a href="https://apcentral.collegeboard.org/pdf/ap21-frq-computer-science-a.pdf?course=ap-computer-science-a">https://apcentral.collegeboard.org/pdf/ap21-frq-computer-science-a.pdf?course=ap-computer-science-a</a></p>
<h2>Part (a) &#8211; <span class="ctext">CombinedTable</span> class</h2>
<pre>public class CombinedTable
{
  <span class="highlight">private SingleTable t1, t2;</span>

  <span class="highlight">public CombinedTable(SingleTable t1, SingleTable t2)</span>
  {
    this.t1 = t1;
    this.t2 = t2;
  }
	
  <span class="highlight">public boolean canSeat(int people)</span>
  {
    int seats = t1.getNumSeats() + t2.getNumSeats() - 2;
    return seats &gt;= people;
  }
	
  <span class="highlight">public double getDesirability()</span>
  {
    double averageView = (t1.getViewQuality() + t2.getViewQuality()) / 2;

    if(t1.getHeight() == t2.getHeight())
       return averageView;
    else
      return averageView - 10;
  }
}
</pre>
<h3>2021 AP CS Exam Free Response Solutions</h3>
<ul>
<li><a href="https://apcomputersciencetutoring.com/exam-review/wordmatch-free-response/">WordMatch Free Response Solution</a></li>
<li><a href="https://apcomputersciencetutoring.com/exam-review/clubmembers-free-response/">ClubMembers Free Response Solution</a></li>
<li><a href="https://apcomputersciencetutoring.com/exam-review/arrayresizer-free-response/">ArrayResizer Free Response Solution</a></li>
</ul>The post <a href="https://apcomputersciencetutoring.com/exam-review/combinedtable-free-response/">CombinedTable free response</a> first appeared on <a href="https://apcomputersciencetutoring.com/exam-review">Review for AP Comp Sci Exam</a>.]]></content:encoded>
					
					<wfw:commentRss>https://apcomputersciencetutoring.com/exam-review/combinedtable-free-response/feed/</wfw:commentRss>
			<slash:comments>9</slash:comments>
		
		
			</item>
		<item>
		<title>ClubMembers free response</title>
		<link>https://apcomputersciencetutoring.com/exam-review/clubmembers-free-response/</link>
					<comments>https://apcomputersciencetutoring.com/exam-review/clubmembers-free-response/#comments</comments>
		
		<dc:creator><![CDATA[Brandon Horn]]></dc:creator>
		<pubDate>Sat, 08 May 2021 18:59:54 +0000</pubDate>
				<category><![CDATA[2021 AP Computer Science Exam Answers]]></category>
		<guid isPermaLink="false">https://apcomputersciencetutoring.com/exam-review/?p=3347</guid>

					<description><![CDATA[<p>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) &#8211; addMembers method public void addMembers(String[] names, int gradYear) { for(String name : names) memberList.add(new MemberInfo(name, gradYear, true)); } Part (b) &#8211; removeMembers method public ...<a class="post-readmore" href="https://apcomputersciencetutoring.com/exam-review/clubmembers-free-response/">read more</a></p>
The post <a href="https://apcomputersciencetutoring.com/exam-review/clubmembers-free-response/">ClubMembers free response</a> first appeared on <a href="https://apcomputersciencetutoring.com/exam-review">Review for AP Comp Sci Exam</a>.]]></description>
										<content:encoded><![CDATA[<p><span class="ctext">ClubMembers</span> free response problem from the 2021 AP Computer Science A Exam.</p>
<p><span id="more-3347"></span></p>
<p>ClubMembers is #3 from the from the 2021 AP Computer Science A Free Response problems.</p>
<p><a href="https://apcentral.collegeboard.org/pdf/ap21-frq-computer-science-a.pdf?course=ap-computer-science-a">https://apcentral.collegeboard.org/pdf/ap21-frq-computer-science-a.pdf?course=ap-computer-science-a</a></p>
<h2>Part (a) &#8211; <span class="ctext">addMembers</span> method</h2>
<pre><span class="highlight">public void addMembers(String[] names, int gradYear)</span>
{
  for(String name : names)
    memberList.add(new MemberInfo(name, gradYear, true));
}
</pre>
<h2>Part (b) &#8211; <span class="ctext">removeMembers</span> method</h2>
<pre><span class="highlight">public ArrayList&lt;MemberInfo&gt; removeMembers(int year)</span>
{
  ArrayList&lt;MemberInfo&gt; goodStanding = new ArrayList&lt;MemberInfo&gt;();	

  int i = 0;
  while(i &lt; memberList.size())
  {
    if(memberList.get(i).getGradYear() &lt;= year)
    {
      MemberInfo removed = memberList.remove(i);
      if(removed.inGoodStanding())
        goodStanding.add(removed);
    }
    else
      i++;
  }
		
  return goodStanding;
}
</pre>
<h3>2021 AP CS Exam Free Response Solutions</h3>
<ul>
<li><a href="https://apcomputersciencetutoring.com/exam-review/wordmatch-free-response/">WordMatch Free Response Solution</a></li>
<li><a href="https://apcomputersciencetutoring.com/exam-review/combinedtable-free-response/">CombinedTable Free Response Solution</a></li>
<li><a href="https://apcomputersciencetutoring.com/exam-review/arrayresizer-free-response/">ArrayResizer Free Response Solution</a></li>
</ul>The post <a href="https://apcomputersciencetutoring.com/exam-review/clubmembers-free-response/">ClubMembers free response</a> first appeared on <a href="https://apcomputersciencetutoring.com/exam-review">Review for AP Comp Sci Exam</a>.]]></content:encoded>
					
					<wfw:commentRss>https://apcomputersciencetutoring.com/exam-review/clubmembers-free-response/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>ArrayResizer free response</title>
		<link>https://apcomputersciencetutoring.com/exam-review/arrayresizer-free-response/</link>
					<comments>https://apcomputersciencetutoring.com/exam-review/arrayresizer-free-response/#comments</comments>
		
		<dc:creator><![CDATA[Brandon Horn]]></dc:creator>
		<pubDate>Sat, 08 May 2021 18:55:14 +0000</pubDate>
				<category><![CDATA[2021 AP Computer Science Exam Answers]]></category>
		<guid isPermaLink="false">https://apcomputersciencetutoring.com/exam-review/?p=3345</guid>

					<description><![CDATA[<p>ArrayResizer free response problem from the 2021 AP Computer Science A Exam. ArrayResizer is #4 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) &#8211; isNonZeroRow method public static boolean isNonZeroRow(int[][] array2D, int r) { for(int c = 0; c &#60; array2D[0].length; c++) if(array2D[r][c] == 0) return false; return ...<a class="post-readmore" href="https://apcomputersciencetutoring.com/exam-review/arrayresizer-free-response/">read more</a></p>
The post <a href="https://apcomputersciencetutoring.com/exam-review/arrayresizer-free-response/">ArrayResizer free response</a> first appeared on <a href="https://apcomputersciencetutoring.com/exam-review">Review for AP Comp Sci Exam</a>.]]></description>
										<content:encoded><![CDATA[<p><span class="ctext">ArrayResizer</span> free response problem from the 2021 AP Computer Science A Exam.</p>
<p><span id="more-3345"></span></p>
<p>ArrayResizer is #4 from the from the 2021 AP Computer Science A Free Response problems.</p>
<p><a href="https://apcentral.collegeboard.org/pdf/ap21-frq-computer-science-a.pdf?course=ap-computer-science-a">https://apcentral.collegeboard.org/pdf/ap21-frq-computer-science-a.pdf?course=ap-computer-science-a</a></p>
<h2>Part (a) &#8211; <span class="ctext">isNonZeroRow</span> method</h2>
<pre><span class="highlight">public static boolean isNonZeroRow(int[][] array2D, int r)</span>
{
  for(int c = 0; c &lt; array2D[0].length; c++)
    if(array2D[r][c] == 0)
      return false;
  
  return true;
}
</pre>
<h2>Part (b) &#8211; <span class="ctext">resize</span> method</h2>
<pre><span class="highlight">public static int[][] resize(int[][] array2D)</span>
{
  int[][] newArray = new int[numNonZeroRows(array2D)][array2D[0].length];

  int newR = 0;
  for(int oldR = 0; oldR &lt; array2D.length; oldR++)
  {
    if(isNonZeroRow(array2D, oldR))
    {
      // could copy elements within row instead
      newArray[newR] = array2D[oldR];
      newR++;
    }
  }		
 
 return newArray;
}
</pre>
<p>The postcondition mentions that <span class="ctext">array2D</span> must be unchanged. I didn&#8217;t see anything in the description or in the examples that prohibited copying references to the existing rows. Although I could see an argument that the contents of each row should be copied into the new array (to prevent later modifications to the returned array from changing the original array), I would argue that the above should receive full credit.</p>
<h3>2021 AP CS Exam Free Response Solutions</h3>
<ul>
<li><a href="https://apcomputersciencetutoring.com/exam-review/wordmatch-free-response/">WordMatch Free Response Solution</a></li>
<li><a href="https://apcomputersciencetutoring.com/exam-review/combinedtable-free-response/">CombinedTable Free Response Solution</a></li>
<li><a href="https://apcomputersciencetutoring.com/exam-review/clubmembers-free-response/">ClubMembers Free Response Solution</a></li>
</ul>The post <a href="https://apcomputersciencetutoring.com/exam-review/arrayresizer-free-response/">ArrayResizer free response</a> first appeared on <a href="https://apcomputersciencetutoring.com/exam-review">Review for AP Comp Sci Exam</a>.]]></content:encoded>
					
					<wfw:commentRss>https://apcomputersciencetutoring.com/exam-review/arrayresizer-free-response/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>Solution to ZombiePlant free response practice question</title>
		<link>https://apcomputersciencetutoring.com/exam-review/zombieplant-solution/</link>
		
		<dc:creator><![CDATA[Brandon Horn]]></dc:creator>
		<pubDate>Fri, 28 Aug 2020 14:13:47 +0000</pubDate>
				<category><![CDATA[Solutions]]></category>
		<guid isPermaLink="false">https://apcomputersciencetutoring.com/exam-review/?p=3317</guid>

					<description><![CDATA[<p>Complete the ZombiePlant practice problem before reviewing the solution. Review the ZombiePlant solution with AP CS Tutor Brandon Horn. Note: This is a new practice problem. Please report any issues with a comment or my contact form. Thanks. public class ZombiePlant { private final int maxPotency; private int treatmentsNeeded; public ZombiePlant(int max, int needed) { ...<a class="post-readmore" href="https://apcomputersciencetutoring.com/exam-review/zombieplant-solution/">read more</a></p>
The post <a href="https://apcomputersciencetutoring.com/exam-review/zombieplant-solution/">Solution to ZombiePlant free response practice question</a> first appeared on <a href="https://apcomputersciencetutoring.com/exam-review">Review for AP Comp Sci Exam</a>.]]></description>
										<content:encoded><![CDATA[<p>Complete the <a href="https://apcomputersciencetutoring.com/exam-review/zombieplant-free-response-practice-question/">ZombiePlant practice problem</a> before reviewing the solution.</p>
<p><span id="more-3317"></span></p>
<p>Review the ZombiePlant solution with <a href="http://mrhorn.com/wp/ap-computer-science-tutor/">AP CS Tutor Brandon Horn</a>.</p>
<p>Note: This is a new practice problem. Please report any issues with a comment or my contact form. Thanks.</p>
<pre>public class ZombiePlant
{
  <span class="highlight">private final int maxPotency;</span>
  <span class="highlight">private int treatmentsNeeded;</span>

  <span class="highlight">public ZombiePlant(int max, int needed)</span>
  {
    maxPotency = max;
    treatmentsNeeded = needed;
  }

  <span class="highlight">public int treatmentsNeeded()</span>
  {
    return treatmentsNeeded;
  }

  <span class="highlight">public void treat(int potency)</span>
  {
    if(potency &gt; maxPotency)
    {
      treatmentsNeeded++;
    }
    else
    {
      if(treatmentsNeeded &gt; 0)
        treatmentsNeeded--;
    }
  }

  <span class="highlight">public boolean isDangerous()</span>
  {
    return treatmentsNeeded &gt; 0;
  }
}
</pre>The post <a href="https://apcomputersciencetutoring.com/exam-review/zombieplant-solution/">Solution to ZombiePlant free response practice question</a> first appeared on <a href="https://apcomputersciencetutoring.com/exam-review">Review for AP Comp Sci Exam</a>.]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>ZombiePlant free response practice question</title>
		<link>https://apcomputersciencetutoring.com/exam-review/zombieplant-free-response-practice-question/</link>
		
		<dc:creator><![CDATA[Brandon Horn]]></dc:creator>
		<pubDate>Fri, 28 Aug 2020 14:12:06 +0000</pubDate>
				<category><![CDATA[AP CS Free Response Practice Questions]]></category>
		<category><![CDATA[Classes and Objects]]></category>
		<guid isPermaLink="false">https://apcomputersciencetutoring.com/exam-review/?p=3286</guid>

					<description><![CDATA[<p>Classes &#38; objects are always tested in the multiple choice and free response sections. Problem description This question involves the implementation of a zombie plant treatment system that is represented by the ZombiePlant class. A ZombiePlant object is created with parameters that specify the maximum potency for a successful treatment and the initial number of ...<a class="post-readmore" href="https://apcomputersciencetutoring.com/exam-review/zombieplant-free-response-practice-question/">read more</a></p>
The post <a href="https://apcomputersciencetutoring.com/exam-review/zombieplant-free-response-practice-question/">ZombiePlant free response practice question</a> first appeared on <a href="https://apcomputersciencetutoring.com/exam-review">Review for AP Comp Sci Exam</a>.]]></description>
										<content:encoded><![CDATA[<p>Classes &amp; objects are always tested in the multiple choice and free response sections.</p>
<p><span id="more-3286"></span></p>
<h2>Problem description</h2>
<p>This question involves the implementation of a zombie plant treatment system that is represented by the <span class="ctext">ZombiePlant</span> class. A <span class="ctext">ZombiePlant</span> object is created with parameters that specify the maximum potency for a successful treatment and the initial number of successful treatments required to cure the plant.</p>
<p>The <span class="ctext">ZombiePlant</span> class provides a constructor and the following methods.</p>
<ul>
<li><span class="ctext">treatmentsNeeded</span>, which returns the number of successful treatments required to cure the plant</li>
<li><span class="ctext">isDangerous</span>, which returns true if the plant requires treatment, false otherwise</li>
<li><span class="ctext">treat</span>, which administers a treatment with the specified potency</li>
</ul>
<p>The following table contains a sample code execution sequence and the corresponding results.</p>
<table border="1px">
<tbody>
<tr>
<th>Statements and Expressions</th>
<th>Value Returned (blank if no value)</th>
<th>Comment</th>
</tr>
<tr>
<td><span class="ctext"><br />
ZombiePlant plant = new ZombiePlant(10, 3);<br />
</span></td>
<td></td>
<td>The plant requires treatments with a potency &lt;= 10. The plant initially needs 3 successful treatments to be cured.</td>
</tr>
<tr>
<td><span class="ctext"><br />
plant.treatmentsNeeded();<br />
</span></td>
<td>3</td>
<td>The plant has not yet been treated, so it still needs 3 treatments to be cured.</td>
</tr>
<tr>
<td><span class="ctext"><br />
plant.isDangerous();<br />
</span></td>
<td>true</td>
<td>The plant still needs at least 1 treatment to be cured, so it is dangerous.</td>
</tr>
<tr>
<td><span class="ctext"><br />
plant.treat(7);<br />
</span></td>
<td></td>
<td>The treatment potency is &lt;= 10, so the treatment is successful.</td>
</tr>
<tr>
<td><span class="ctext"><br />
plant.treatmentsNeeded();<br />
</span></td>
<td>2</td>
<td>The plant now needs 2 successful treatments to be cured.</td>
</tr>
<tr>
<td><span class="ctext"><br />
plant.treat(11);<br />
</span></td>
<td></td>
<td>The treatment potency is not &lt;= 10, so the treatment is not successful.</td>
</tr>
<tr>
<td><span class="ctext"><br />
plant.treatmentsNeeded();<br />
</span></td>
<td>3</td>
<td>The failed treatment increased the number of successful treatments needed for the plant to be cured by 1.</td>
</tr>
<tr>
<td><span class="ctext"><br />
plant.treat(10);<br />
</span></td>
<td></td>
<td>The treatment potency is &lt;= 10, so the treatment is successful.</td>
</tr>
<tr>
<td><span class="ctext"><br />
plant.treatmentsNeeded();<br />
</span></td>
<td>2</td>
<td>The plant now needs 2 successful treatments to be cured.</td>
</tr>
<tr>
<td><span class="ctext"><br />
plant.isDangerous();<br />
</span></td>
<td>true</td>
<td>The plant still needs at least 1 treatment to be cured, so it is dangerous.</td>
</tr>
<tr>
<td><span class="ctext"><br />
plant.treat(8);<br />
</span></td>
<td></td>
<td>The treatment potency is &lt;= 10, so the treatment is successful.</td>
</tr>
<tr>
<td><span class="ctext"><br />
plant.treat(4);<br />
</span></td>
<td></td>
<td>The treatment potency is &lt;= 10, so the treatment is successful.</td>
</tr>
<tr>
<td><span class="ctext"><br />
plant.treatmentsNeeded();<br />
</span></td>
<td>0</td>
<td>The successful treatments reduced the number of treatments needed to 0.</td>
</tr>
<tr>
<td><span class="ctext"><br />
plant.isDangerous();<br />
</span></td>
<td>false</td>
<td>The plant has been cured. It is no longer dangerous.</td>
</tr>
<tr>
<td><span class="ctext"><br />
plant.treat(4);<br />
</span></td>
<td></td>
<td>Additional treatments with a potency &lt;= 10 have no effect.</td>
</tr>
<tr>
<td><span class="ctext"><br />
plant.treatmentsNeeded();<br />
</span></td>
<td>0</td>
<td>The additional treatment with a potency &lt;= 10 had no effect.</td>
</tr>
<tr>
<td><span class="ctext"><br />
plant.isDangerous();<br />
</span></td>
<td>false</td>
<td>The plant remains cured.</td>
</tr>
<tr>
<td><span class="ctext"><br />
plant.treat(11);<br />
</span></td>
<td></td>
<td>The additional treatment potency is not &lt;= 10, so the treatment causes the plant to become dangerous again.</td>
</tr>
<tr>
<td><span class="ctext"><br />
plant.treatmentsNeeded();<br />
</span></td>
<td>1</td>
<td>The failed treatment increased the number of successful treatments needed for the plant to be cured by 1.</td>
</tr>
<tr>
<td><span class="ctext"><br />
plant.isDangerous();<br />
</span></td>
<td>true</td>
<td>The plant is now dangerous again.</td>
</tr>
<tr>
<td><span class="ctext"><br />
plant.treat(12);<br />
</span></td>
<td></td>
<td>The treatment potency is not &lt;= 10, so the treatment is not successful.</td>
</tr>
<tr>
<td><span class="ctext"><br />
plant.treatmentsNeeded();<br />
</span></td>
<td>2</td>
<td>The failed treatment increased the number of successful treatments needed by 1.</td>
</tr>
<tr>
<td><span class="ctext"><br />
plant.isDangerous();<br />
</span></td>
<td>true</td>
<td>The plant is still dangerous.</td>
</tr>
</tbody>
</table>
<p>Write the complete <span class="ctext">ZombiePlant</span> class, including the constructor and any required instance variables and methods. Your implementation must meet all specifications and conform to the example.</p>
<p>See the <a href="https://apcomputersciencetutoring.com/exam-review/zombieplant-solution/">ZombiePlant solution</a> or review it with <a href="http://mrhorn.com/wp/ap-computer-science-tutor/">AP CS Tutor Brandon Horn</a>.</p>The post <a href="https://apcomputersciencetutoring.com/exam-review/zombieplant-free-response-practice-question/">ZombiePlant free response practice question</a> first appeared on <a href="https://apcomputersciencetutoring.com/exam-review">Review for AP Comp Sci Exam</a>.]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/

Page Caching using disk: enhanced (Page is feed) 
Minified using disk

Served from: apcomputersciencetutoring.com @ 2023-03-04 16:43:02 by W3 Total Cache
-->