Advanced Placement Computer Science
Course Overview
Course Policies
Computer
Science AP
Syllabus
Class Schedule
Homework
Labs
Projects
Extra Credit
Study
Material
Grades
Computer Science 2 AP
Get Software
Useful Resources
Teacher Information
|
Homework for Computer Science AP
Assignments or readings are to be
done by the date specified.
- AP Review Part 3 Worksheet. This will not be
collected. But the final AP Review Test will cover all that was
covered in Parts 1 & 2. In addition, it will cover chapters
12 & 13. Note: At least one of these problems will appear on
the exam.
- Write a method public static boolean compareFiles (String
one, String two): Tell whether the two text files have exactly
the same contents.
- Write a method public static void mergeTwo
(BufferedReader inOne, BufferedReader inTwo, String outName):
Read from two BufferedReaders known to have their lines in ascending
order. Write all lines to a file named outName so that the file
has its lines in ascending order.
- Write the independent method public static void
selectionSort (Comparable[] item, int size) to sort the size elements
in ascending order. Include any necessary submethod.
- Write the independent method public static void
insertionSort (Comparable[] item, int size) to sort the size elements
in ascending order. Include any necessary submethod.
- Rewrite the insertionSort method to use binary search to
find the place where the next value is to be inserted.
Essay: Is this faster or slower than your code for problem 4? Why?
- For the FRQ due on 4/23/04 do this problem
on paper. It is due at the start of class and is worth 2 points.
- AP Review Part 2 Worksheet. Due on 4/23/04.
This covers chapters 6, 7, 9 and 11 and should be done on paper and
must be done individually. This is worth 10 points
- Write an application program that reads in a single
decimal
number from the keyboard that represents the circumference of a circle
and prints out the diameter and area of that circle. Use 3.14159
as
the value of pi.
- Write MathOp methods to calculate the sine and cosine of
any
number of radians correct to eight decimal places. Use the
formulas
cosine(x) = 1 - x2/2 + x4/(2*3*4) - x6/(2*3*4*5*6)... and sine(x)
= x
-x3/(2*3) + x5/(2*3*4*5) - x7/(2*3*4*5*6*7)...
- Write an independent class method named endsWith with two
String parameters big and little: It tells whether big equals
someString + little.
- Write an independent method with a parameter x that
returns x
itself unless (a) x is larger than 20, in which case it returns 20, or
(b) x is smaller than 10, in which case it returns Do not
use any
boolean expression; use both Math.max and Math.min.
- Modify Listing 7.4 in the book to print the birth year in
the 1960's that occurs most frequently.
- Write a WorkerList method public WorkerList mergeList:
The
executor creates and returns a new WorkerList object containing all the
values in both lists. Its size is the sum of the two and, if both
lists are ascending order, then the list returned also has its values
in ascending order (in other words, code on the assumption both are in
ascending order). This is based on the WorkerList class developed
in
Chapter 7
- List five different RuntimeExceptions and state a short
example of when they could be thrown.
- The addMore method in Listing 11.3 from the book returns
null
if you try to add a number for which the result is not computable,
i.e., when the add method returns null. Revise it to return the
sum of
all the numbers up to that point.
- Rewrite the equals method for the Time class in the text
to
execute faster by using a try/catch-statement rather than an
if-statement. This is based on the Time class in Chapter 11.
- Write an independent class method that prints out the
digits of
a given positive integer in base 8, but in reverse order (e.g., prints
"213" for 2 + 1*8 + 3*64).
- For the FRQ due on 4/7/04 (or 4/14/04) do this
problem on paper. It is due at the end of class and is worth
2 points. The answers are here
- AP Review Part 1 Worksheet. Due on
4/9/04 or
4/16/04. This covers chapters 1 - 5. To be done
individually, on paper and is worth 5 points.
- Write an application program that asks
the user for a
single int value and then announces the power of 2 (1, 2, 4, 8, 16, 32,
etc.) closest to that input (take the lower one for a tie). But
if the input is not a positive integer, just say "not acceptable".
- Explain overriding, with examples.
- Explain overloading, with examples.
- Write a MathOp class method that returns the sum of all
the
values between its two int parameters, inclusive of the
parameters. Note: The first parameter could be larger than
the second, or it could be smaller.
- Write an independent method that has one String parameter
and returns (a) zero if the String is not the name of one of the twelve
months (properly spelled, with only the initial letter capitalized),
otherwise (b) the normal number of days in that month. Your logic
should not make more than five comparisons for any value of the
parameter.
- 3/31/04 - Chapter 13 Assignments
Read Chapter 13 sections 13.1,
13.2, 13.3, 13.4
You need to do the following problems from Chapter 13: 13.7, 13.9, 13.13, 13.15, 13.16, 13.18,
13.19, 13.26. Worth 5 points
Extra Credit problems (also due on 3/31):
13.4, 13.10, 13.17, 13.28,
13.29 Worth 2 points
- 3/11/04 - Chapter 12 Assignments
Read Chapter 12
sections 12.1, 12.2, 12.3, 12.4, 12.5
You need to the following problems from Chapter 12: 12.1, 12.6, 12.14, 12.19, 12.20, 12.21
(you do not need to provide sample input files for the
homework submission... but I HIGHLY recommend you make them for
yourself to ensure your code actually works)
- 2/17/04 - Chapter 11 Assignments
Read Chapter 11 sections 11.1-11.4
You need to do the following problems from Chapter 11: 11.1, 11.2, 11.3, 11.6, 11.9, 11.11
- 2/3/04 - Chapter 9 Assignments
Read Chapter 9 sections 9.1, 9.2,
9.3, 9.4, 9.9
You need to do the following problems from Chapter 9: 9.1, 9.3, 9.9, 9.11, 9.16, 9.40
Last semester's homework
last
updated on 4/25/04
Copyright (C) 2004 Jim Casaburi
|
|