CS 102 Lab 8: Word Sorter
Objective: To gain experience with File Handling, Strings, and Sorting

 

In this lab, you will write a program WordSorter that can read a large number of words from a file, sort them in a non-decreasing order by their length, and save the result to a file.

Write a java program that can load the words in the dictionary, display the words in non-decreasing order of their length (the words of the same length can appear in any order), and save the list of the sorted words to a file. The number of words in the dictionary is no more than 40,000.

First download the following two files:

The file dictionary.txt contains a list of words in an alphabetic order. The file WordSorterDemo.class is a demo of the program. You can run the compiled demo by typing

java WordSorterDemo

If you have successfully finished this lab, your program should behave in the same ways as the demo. You can choose to implement any appropriate sorting algorithm, but the performance of your program should not be much worse than the given demo.

 

 

Grading Point Allocations

Value Feature
Good Style (6 pts total)
2 Appropriate comments
1 Good choice of names
1 Good use of boolean expressions
1 Not doing more work than necessary
1 Appropriate parameters
Correctness (14 pts total)
2 Load a file
2 list the words
4 Sort the words correctly
2 Display the sorted words
2 Save the result in a file
2 No other problems