10-18 Class Notes CS 107

10-18 Class Notes CS 107 - See updates online to program #4...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the 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.

Page1 / 5

10-18 Class Notes CS 107 - See updates online to program #4...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online