Mehran Sahami Handout #34
CS 106A November 5, 2007
Section Handout #6: More Arrays and HashMaps
Portions of this handout by Eric Roberts
1. Image processing (Chapter 11, exercise 12, page 458)
Write a method flipHorizontal that works similarly to the flipVertical method presented in the chapter except that it reverses the picture in the horizontal dimension. Thus, if you had a GImage containing the image on the left (of Jan Vermeer’s The Milkmaid, c. 1659), calling flipHorizontal on that image would return a new GImage as shown on the right:
2. Name Counts
Write a program that asks the user for a list of names (one per line) until the user enters a blank line (i.e., just hits return when asked for a name). At that point the program should print out how many times each name in the list was entered. You may find that using a HashMap to keep track of the information entered by user may greatly simplify this problem. A sample run of this program is shown below.
CS 106A November 5, 2007
Section Handout #6: More Arrays and HashMaps
Portions of this handout by Eric Roberts
1. Image processing (Chapter 11, exercise 12, page 458)
Write a method flipHorizontal that works similarly to the flipVertical method presented in the chapter except that it reverses the picture in the horizontal dimension. Thus, if you had a GImage containing the image on the left (of Jan Vermeer’s The Milkmaid, c. 1659), calling flipHorizontal on that image would return a new GImage as shown on the right:
2. Name Counts
Write a program that asks the user for a list of names (one per line) until the user enters a blank line (i.e., just hits return when asked for a name). At that point the program should print out how many times each name in the list was entered. You may find that using a HashMap to keep track of the information entered by user may greatly simplify this problem. A sample run of this program is shown below.
0 comments:
Post a Comment