Computer Science APEA 15-100, Summer 2009
Homework 7
Due: Fri 10-Jul-2009 at 8:59am (email copy only)
(no late submissions accepted).
Read these instructions first!
public static void testNthPerfectNumber() {
System.out.print("Testing nthPerfectNumber... ");
assert(nthPerfectNumber(-5) == -1);
assert(nthPerfectNumber(0) == -1);
assert(nthPerfectNumber(1) == 6);
assert(nthPerfectNumber(2) == 28);
assert(nthPerfectNumber(3) == 496);
System.out.println("Passed all tests!");
}
Helper Method: unspecified (but required!)
Again, in writing your nthPerfectNumber method, you must use a
well-conceived helper method. You must also include a test method for your
helper method (and, again, you will be graded, in part, on the quality of
the test cases in that test method).
Note: As should be apparent,
decomposition into
helper
methods is a great way to design your programs. You are expected
to use this approach in all future programming assignments.
(larger
image with details)Carpe diem!