{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

10-18 Class Notes CS 107

# 10-18 Class Notes CS 107 - 10-18 Class Notes CS 107 Monday...

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

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.

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 5

10-18 Class Notes CS 107 - 10-18 Class Notes CS 107 Monday...

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

View Full Document
Ask a homework question - tutors are online