This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: See updates online to program #4 description. See also sample video. Note that deadline has been extended to Tuesday 10/26 at noon. Announcements: Questions? Last Time: Making an array of Square; Bubble Sort Comments on program #4 More on Sorting; Today: Binary Search; More Arrays examples: Command line args; Dynamic Array Multidimensional arrays example Use a sorted array of integers corresponding to the values in the lightGray dice. Calculate how many lightGray dice there are (that have been selected by the user). Store this information in some variable (e.g. int howMany = 0; a. Create an integer array of exactly this size, e.g.: int values = new int[ howMany]; b. Copy the lightGray dice values into this array c. Sort the values array in ascending order (use bubble sort, or selection sort (p.384)) d. Now it is much easier to calculate scores. Hint: Think of how you could do this for "white" squares rather than "lightGray" squares, to see if a user has "Farkled" To do this, follow these steps: Hints for how to calculate score for Program #4 Think about how you might want to do a selection sort , where you find the largest (or smallest) value on each pass through the data, swapping it into place. How does this compare to Bubble sort?...
View Full Document
This note was uploaded on 02/10/2012 for the course COP 2271 taught by Professor Reed during the Fall '10 term at University of Central Florida.
- Fall '10
- Computer Programming