| 18 | === Sort3 |
| 19 | Use only if-statements and/or nested if-statements to sort three numbers in ascending order. Do not use for-loops, or call any methods besides the ones you write. For an extra challenge, write the static method using only 3, un-nested if-statements, which is the minimum number. |
| 20 | |
| 21 | Best results if you think about the code yourself, and not look it up. |
| 22 | |
| 23 | === !MovingAverage |
| 24 | A moving average is the average of the {{{n}}} most recent numbers. Design a data type (see the Internet for a definition) that has the following API that computes the moving average of a set of {{{n}}} numbers stored in the data type: |
| 25 | |
| 26 | '''public class !MovingAverage''' |
| 27 | ==== !MovingAverage(int n) |
| 28 | Constructor. Takes a parameter {{{n}}} that determines how many of the recent values to average. |
| 29 | ==== void addValue(double) |
| 30 | Adds a value to the list. Does not directly change the average. The average should be updated immediately to reflect this addition. |
| 31 | ==== double getAverage() |
| 32 | Returns the moving average of the most ''recent'' {{{n}}} values entered. |
| 33 | ==== void clear() |
| 34 | Clears the list. getAverage() should now return 0. |
| 35 | |
| 36 | === !RomanNumeralInterpreter |
| 37 | Write a static method that takes a string input argument (the Roman numerals) and returns the Arabic ("normal") equivalent. Use conventional, contemporary rules for Roman numerals (see [http://en.wikipedia.org/wiki/Roman_numerals wikipedia]). |
| 38 | |
| 39 | === !QueenCheck |
| 40 | Given a chess board (8-by-8) populated entirely by queens, determine if any of the queens are threatened by another. Write a static function to determine this, given a 2D boolean array where queens are represented by {{{true}}}. |
| 41 | |
| 42 | ''Remember, queens threaten other chess pieces when they lie on the same row, column, or diagonal.'' |
| 43 | |
| 44 | === !CodeBreaker |
| 45 | You will be provided a lexicon of common words in {{{lexicon.txt}}} which is in the same directory. Write a program that takes in a Caesar-ciphered string and decrypts it reliably (> 95% success rate). You will not be given the shift key. Do not look at the ciphertext to help with the decoding; your program needs to be able to decode it without human assistance. |
| 46 | |