This post assumes you know how to do the following in Java:
- Read from a file
- Write to a file
- Set up a loop to read multiple lines from a file
If you don’t know how to do this, go back to the last post on this subject and complete it first.
We are now going to use a large dictionary file to create some useful text processing algorithms. Please download the file words.txt words.txt and save it to the root of your machine, ie as “c:\words.txt”.
- Task 1: Write a program that counts the number of words in this file.
- Task 2: Write a program that counts the number of characters in this file.
- Task 3: Write a program that asks for a specific word and prints out the line number at which that word occurs.
- Task 4: Write a program that asks for a specific number of characters n and prints out the number of words in the file that have n characters.
- Task 5: Write a program that asks for a specific character sequence and prints out all the words that contain that character sequence.
- Write a program that saves the list in a new file, sorted by word length.
- Write a program that asks the user to enter a word and the prints out all the anagrams of that word.
- Write a program that plays hangman by guessing letters randomly.
- Write a program that plays hangman using the dictionary to make intelligent guesses.
- Write a program that allows the user to specify a wordsearch grid, and then uses the dictionary to solve it.
- Write a program that plays Boggle.