CMSI 185
Homework #3
Due: 2009-03-05

Readings: Read Chapter 4 of David Eck's text. Make sure you read the entire chapters, including material such as quizzes, exercises, and solutions (if any) at the end of each chapter.

In this homework assignment, you are to implement variations on each of the problems in Chapter 4 of Eck's book. Eck provides solutions to each of the problems, accompanied by some nice discussion. You will use his solutions as a starting point for your own work.

There are a few requirements that apply to every problem, be sure to follow them:

Here are the problems:

  1. (15 pts) Exercise 4.1 in the text, but instead of a printCapitalized method which returns nothing, use a method which returns a new string which is the capitalized version of the parameter.
  2. (15 pts) Exercise 4.2 in the text, but implement a better hexValue method. Instead of a switch statement, use the string "0123456789ABCDEF" with charAt and toUpperCase methods to make the entire method body only one line long.
  3. (15 pts) Exercise 4.3 in the text, but use a Random object, not the Math.random() method.
  4. (20 pts) Exercise 4.4 in the text, but take the number of experiments as a command line argument.
  5. (20 pts) Exercise 4.5 in the text, but use an enum for the direction, and brighten the mosaic with shades of cyan, rather than red.
  6. (15 pts) Exercise 4.6 in the text, but produce circles instead of squares.