AP CS Assignments
Assignments by week:
Fall Term:
Winter Term:
Spring Term:
Monday, May 6
Description
AP Review
Homework
  • Complete the following methods as specified in their comments.

    1. /**
       * Return the average of all values in a 2D array.
       *
       * @param a The 2D array of values to average
       *
       * @return double The average of all values in the array
       */
      public static double average(double[][] a);
          
    2. /**
       * Given a two-dimensional array of Strings, return a new array
       * with the values reflected over the major diagonal.  For example:
       *
       * A B C D E              A F K P U
       * F G H I J              B G L Q V
       * K L M N O   becomes:   C H M R W
       * P Q R S T              D I N S X
       * U V W X Y              E J O T Y
       *
       * Precondition: a is square (rows == cols)
       *
       * @param a The 2D array to use as input
       *
       * @return String[][] The reflected array
       */
      public static String[][] reflect(String[][] a);
          
    3. /**
       * Given a two-dimensional array, shift all the values in place
       * by the amount specified.  The values that are shifted off the
       * end should wrap around to the beginning.  Assume that values
       * are ordered by their row, and then by their column.  For example:
       *
       * A B C D                           J K L A
       * E F G H   shifted by 3 would be:  B C D E
       * I J K L                           F G H I
       *
       * @param a The array to shift
       * @param amt The amount to shift by (you may assume it is greater
       *            than zero and less than the number of elements in the array)
       */
      public static void shift(String[][] a, int amt);
          
Tuesday, May 7
Description
AP Review
Homework
  • Complete the following methods as specified in their comments. Only use the methods available on the Java Quick Reference from the AP board (don't use other methods of String that are available in the standard Java library).

    1. /**
       * Given a string to search, count the number of commas that
       * occur in the string.  You may assume s is not null.
       *
       * @param s The String to search inside of
       *
       * @return int The number of commas in the String
       */
      public static int countCommas(String s);
          
    2. /**
       * Given an input string, return a copy of the string where all
       * instances of the "find" string have been replaced by the
       * "replace" string.  For example, if the input string s was
       * "I love to eat cheese", string f was "e", and string r was "*",
       * the method would return "I lov* to *at ch**s*".
       *
       * @param s The String to use as input
       * @param f The substring to find
       * @param r The substring to use as a replacement
       *
       * @return String A copy of "s" with all substring "f" instances replaced by "r" instances.
       */
      public static String replaceAll(String s, String f, String r);
          
Thursday, May 9
Description
AP Review
Homework
Friday, May 10
Description
AP Practice Test
Homework
  • Reivew the reference and course description above. We'll go over any final topics on Monday before the exam.