CMSI 185
Homework #4
Due: 2009-04-07

Readings: Read Chapter 5 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 a couple of the problems in Chapter 5 of Eck's book, as well as one class of your own. Eck provides solutions to each of his 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. (20 pts) Exercise 5.2 in the text, but add a method to return the mode of the dataset. The mode is a value that appears most often. For example, the mode of the set [3 4 7 4 6] is 4. This problem is a little harder than it looks.
  2. (60 pts) Modify Exercise 5.3 in the text to compute statistics for the number of rolls until certain rolls from the game of Yahtzee come up. You can find details of the game online, but all you need to do for this assignment is

    You are not required to write methods for small straights and large straights, but you are encouraged to try if you have time.

  3. (20 pts)Exercise 5.6 in the text, but fix up the toString() methods to avoid switch statements. Instead, pick out the values using the substring method from the String class on the string " A 2 3 4 5 6 7 8 910 J Q K", and do a similar thing to pick out actual suit characters for Suit objects (see http://en.wikipedia.org/wiki/Miscellaneous_Symbols).