Java Reference
In-Depth Information
3. Write a program that processes a data file of students' course grade data. The data arrive in random order; each line
stores information about a student's last name, first name, student ID number, grade as a percentage, and letter
grade. For example, here are a few lines of data:
Smith Kelly 438975 98.6 A
Johnson Gus 210498 72.4 C
Reges Stu 098736 88.2 B
Smith Marty 346282 84.1 B
Reges Abe 298575 78.3 C
Your program should be able to sort the data by any of the columns. Use Comparator s to achieve the sort orderings.
Make the data sortable by last name, student ID, and grade percentage in ascending and descending order. For exam-
ple, here are the lines of student data sorted a few different ways:
Student data, by last name:
Johnson Gus 210498 72.4 C
Reges Stu 098736 88.2 B
Reges Abe 298575 78.3 C
Smith Kelly 438975 98.6 A
Smith Marty 346282 84.1 B
Student data, by student ID:
Reges Stu 098736 88.2 B
Johnson Gus 210498 72.4 C
Reges Abe 298575 78.3 C
Smith Marty 346282 84.1 B
Smith Kelly 438975 98.6 A
4. Write a program that discovers all anagrams of all words listed in an input file that stores the entries in a large dic-
tionary. An anagram of a word is a rearrangement of its letters into a new legal word. For example, the anagrams of
“share” include “shear”, “hears”, and “hares”. Assume that you have a file available to you that lists many words,
one per line. Your program should first read in the dictionary file and sort it, but instead of sorting in alphabetical
order it should sort according to each word's canonical form. The canonical form of a word contains the same letters
as the original, but in sorted order. Thus, the canonical form of “computer” is “cemoprtu”, and the canonical form of
“program” is “agmoprr”. When your dictionary file is sorted, the word “program” would be placed before the word
“computer”, because its canonical form comes first in alphabetical order. Write code to retrieve a word's canonical
form and a Comparator that compares words by using their canonical forms.
Search WWH ::




Custom Search