Computer Science 15-110, Spring 2010
Recitation for Week #4
- Return and Review Quiz2
-
Review Hw3
-
CA-Directed Lab
- isPrime and nthPrime
- Nested Loops
and Nested Loops with Graphics
- Student-Directed
(Collaborative) Lab
- Methods in the Class Notes
-
Print the numbers from 1 to 5
-
Print the numbers from 1 to n
-
Print the sum of the numbers from 1 to n
-
Print the sum of the odd numbers from 1 to n
-
Using "if"
-
Using a different increment
-
Print the letters in a String
-
Print the letters in a String in reverse
-
Division by Subtraction
- More Practice
- Print the Digits of
an Integer
- The sum of the
digits of an integer
- Letter Counter
- Case-insensitive
Letter Counter
- Even More Practice
- 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.
- 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.
-
CA-Directed Lab
- 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?
- 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!
- Student-Directed
(Collaborative) Lab
- 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!
-
Print the numbers from 1 to 5
-
Print the numbers from 1 to n
-
Print the sum of the numbers from 1 to n
-
Print the sum of the odd numbers from 1 to n
-
Using "if"
-
Using a different increment
-
Print the letters in a String
-
Print the letters in a String in reverse
-
Division by Subtraction
- More Practice
- 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).
- 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.
- 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.
- 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.
- 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