Object Oriented Programming in Java

Module [M11] - Sets & Maps

We continue our exploration of Java Collections with two new data structures; Sets & Maps.

  • Textbook Reading Assignments
  • The following sections of the textbook are assigned for this module.
    • Chapter #21 – Sets & Maps

Module Learning Outcomes

In this module, you will develop further your programming skills as follows;

Tracing
Ability to read and trace Java programs leveraging Sets & Maps.
Implementing
Ability to write Java programs leveraging Sets & Maps.
Testing
Ability to develop tests for Java programs leveraging Sets & Maps.
Debugging
Ability to troubleshoot Java programs leveraging Sets & Maps.
Designing
Ability to design Java programs leveraging Sets & Maps.

Please note that some of the following exercises will require your programs to accept command line arguments. You may either decide to work using the command line prompt to run these or use the feature of your IDE that allows you to specify command line arguments when you run your project. All IDEs support this feature.

For JGrasp, you need to go to the Build menu then check the Run Arguments checkbox. This will provide you with a input line of text, right above your source code pane, where you may enter what you would pass to your program if you were running it at the command line.

If you bump into problems with this, do not hesitate to post in the support forum or even the module's forum.

  • A01 - Display nonduplicate words in ascending order
  • File Link: YouTube
  • This exercise is practice exercise #21.2 in the 11th edition of our text Write a program that reads words from a text file and displays all the nonduplicate words in ascending order. The text file is passed as a command-line argument.
  • A02 - Count consonants and vowels
  • File Link: YouTube
  • This exercise is practice exercise #21.4 in the 11th edition of our text Unlike what is specified in the textbook, let us make this program accept the name of the file it needs to read as a command line argument instead of having it prompts the user to enter a text file name. We will then display the number of vowels and consonants in the file. Use a set to store the vowels A, E, I, O, and U so that you may then compare what you are reading from the file to the members of this set in order to help you determine which characters are vowels.
  • A03 - Count the occurrences of numbers entered
  • File Link: YouTube
  • This exercise is practice exercise #21.6 in the 11th edition Write a program that reads an unspecified number of integers and finds the one that has the most occurrences. The input ends when the input is 0. For example, if you entered 2 3 40 3 5 4 3 3 3 2 0, the number 3 occurred most often. If not one but several numbers have the most occurrences, all of them should be reported. For example, since 9 and 3 appear twice in the list 9 30 3 9 3 2 4, both occurrences should be reported.
  • B01 - HashSets
  • This exercise is #21.1 in the 10th edition of our text.
  • B02 - Occurences Counter
  • This exercise is #21.6 in the 10th edition of our text.
  • B03 - Web Crawler
  • This exercise is #21.14 in the 10th edition of our text.
  • B04 - Addition Quiz
  • This exercise is #21.15 in the 10th edition of our text.
  • B05 - Syntax Highlighting
  • This exercise is #21.5 in the 10th edition of our text.