Computer Science 15-110, Spring 2010
Recitation for Week #4

1. Return and Review Quiz2
2. Review Hw3
3. CA-Directed Lab
4. Student-Directed (Collaborative) Lab
1. Methods in the Class Notes
2. More Practice

1. Return and Review Quiz2
CA's will return and briefly review highlights of quiz2.  Students needing deeper review of the material should set up a separate meeting with their CA or instructor.

2. Review Hw3
CA's will briefly review highlights of hw3.  Students needing deeper review of the material should set up a separate meeting with their CA or instructor.

3. CA-Directed Lab
1. isPrime and nthPrime
Under CA direction, write isPrime and nthPrime from scratch.  Compare your solutions to the isPrime and nthPrime solutions in the class notes.  Why does isPrime use a for loop whereas nthPrime uses a while loop?

2. Nested Loops and Nested Loops with Graphics
Review the course notes on Nested Loops and Nested Loops with Graphics.  Be sure to understand how nested loops work!

4. Student-Directed (Collaborative) Lab
1. Methods in the Class Notes
Be sure you can write all these methods (taken from the class notes) from a blank compiler without referring to the class notes!
2. More Practice
1. Print the Digits of an Integer
Write a void method that takes an int n, and prints the digits of n from right-to-left, one per line.  So, for the number 832, you would print 2, then 3, then 8.  You may only use / and % for arithmetic (in particular, you may not construct powers of 10 in any way -- the clearest and most efficient solution does not require that).

2. The sum of the digits of an integer
Write a method that takes a possibly-negative int and returns the (always-positive) sum of its digits.

3. Letter Counter
Write a method that takes a String and a char, and returns a count of the number of times the given char occurs in the String.  This method should be case-sensitive, so "Go Steelers" would contain the letter 's' only once.

4. Case-insensitive Letter Counter
Repeat the previous problem, but this time make your test case-insensitive, so "Go Steelers" would contain the letter 's' twice.

5. Even More Practice
Time permitting, CA's will offer even more problems for students to work on (say, using nested loops to create interesting 2d graphical patterns, though this is not a requirement).

carpe diem   -   carpe diem   -   carpe diem   -   carpe diem   -   carpe diem   -   carpe diem   -   carpe diem   -   carpe diem   -   carpe diem