CS 1713 Introduction to Computer Science, Spring 2010 Exam 2 Comments
The exam average was 72.
The problems on the first part of the exam were easy. If you could not
get at least 65 points on the first part, you are not prepared to continue
this course. If you got 60 or below on this exam, please see me.
- Use single quotes for a character, double quotes for strings.
- Using indexOf is the simplest way to do this problem.
- Don't forget to initialize the count.
- sum must be initialized, avoid integer division, and avoid division by 0.
- Initialize the count.
- It is useful to declare a local variable, speedOverLimit.
- All boxes contain numbers, no arrows in this diagram.
- The three variable boxes contain tails of arrays. An arrow head
points to an array. Make your array boxes large enough to show
more than one value. Showing the array indices is optional.
- An object is shown as a rectangular box containing its attributes.
Each variable should be a named box. The names should be the names of
object attributes, in this case, side1, side2, and
side3. We know that these are the names of the attributes
because the class has methods called setSide1 and
setSide2. Do not make your objects look like arrays
(unless they are arrays).
- You only need one instance of Random, but you need to use it
twice.
- This was one of the two hardest problems on the exam, but with one of the
shortest solutions. Several students had the right idea but had the
wrong end for the final string.
- This is almost the same as the fence post problem done in the notes
but with a bracket at the front and one at the end. Note that the
two brackets are always printed and each is printed exactly once.
- This gave students the most trouble. To analyze this, notice that the
outer loop always prints exactly one line and its body is executed 5 times.
The body of the inner loop is also executed 5 times, so 5 numbers are
printed per line.
solutions