15-100 Sections U-V-AA / Spring 2009
Midterm Exam #1  (
Programming Portion)
Exam Date:  Tue 3-Mar-2009

2 Questions + 1 Bonus Question / 20 Minutes
All questions are equally weighted (10 points each / 20 points total)


Notes:

1.      printMostFrequentDigit
Write a method, printMostFrequentDigit, that prints the digit that occurs most frequently in the file.  In case of a tie, print all such digits in order from least to greatest.

2.      printOddsOf20OrMore
If you roll 5 six-sided dice and add their values, the sum must be between 5 and 30 (right?).  Write a method, printOddsOf20OrMore, that uses Monte Carlo methods to compute the odds that this sum is at least 20 or greater.  As usual, use enough trials to get a reasonably accurate result.  Hint:  remember to create only one instance of Random!

3.      Bonus/Optional:  sort
Write a method that takes an array of int’s and sorts them without calling Arrays.sort.  Write a short explanation in a comment as to how your method works.