A java program that computes anagrams of words

write a program name that prompt the user for a user input file, reads the input words and computes anagram of words. An anagram of a word is apermutation of the letters in that word; for example, “stop” is an anagram of “tops”.

As indicated, the input to the program is a list of words from a user input file. The output is a list containing the same words, but with anagrams displayed on thesame line both on the screen and the output file. The output file must be named output.txt.

The input file, may look like the following: You must prompt the user for the name of the input file.

Pans naps


opt this that




and so on.

Here are some requirements for the program:

1. When determining if two words are anagrams, the program must treat upper and lower case letters as equivalent (thus “Pans” and “snap” are anagrams) and ignorepunctuation marks (“it’s” and “Sit” are anagrams). However, the program must display words with their original capitalization and punctuation – as shown above.

2. The “word” is assumed to be any series of nonblank characters; words may be separated by any number of white-space characters. Any number of words may appear on aline,
including none. You may assume that no word is more than 12 characters long. And maximum number of words would be 50.

3. The program must work even if the input file is empty. If this is the case print a message saying that “the input file is empty” and then terminate theprogram.

4. The program must test the number of characters per word. If a word consist of more than 12 characters, the program should ignore that word and continue. That wordwould also be ignored in the total number of words of 50.

5. The program must also test the number of words. If there are more than 50 words, print a message saying that “there are more than 50 words in the input file” andthen terminate the program


Expert Solution
No answers

Submit Your Answer