Question
An anagram is a word obtained by reordering the letters of another word. For example, once and cone are anagrams. Note that each letter must
An anagram is a word obtained by reordering the letters of another word. For example, once and cone are anagrams. Note that each letter must be reused exactly once, so anagrams must have the same number of letters.
Which word in the English language has the most anagrams? Let us take words in the English language to mean words in the le words.txt, which is posted on Moodle.
Write a program called MostAnagrams to nd the word with the most anagrams. Your program should take no input and produce a single integer, the maximum number of anagrams, as output.
For this problem you may nd the String method toCharArray(), the String constructor that takes a character array argument, and the method java.util.Arrays.sort() useful
This is the starter code given by professor:
import java.io.File; import java.io.FileNotFoundException; import java.utilScanner; import java.util.ArrayList; public class MostAnagrams public static void main(String 1 args) File file -new File("../resource/asnlib/publicdata/words.txt"); int max 0; try Scanner scannernew Scanner(file); while (scanner.hasNext)) f String line - scanner.next (); // read in the next word // Now do something with the word scanner.close); catch (FileNotFoundException e) { e.printStackTrace(); compute max, the maximum number of analgrams for any word System.out.println( max)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started