Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that discovers all anagrams of all words listed in an input file

ID: 3658670 • Letter: W

Question

Write a program that discovers all anagrams of all words listed in an input file that stores the entries in a large dictionary. An anagram of a word is a rearrangement of its letters into a new word. For example, the anagrams of "share" include "shear", "hears", and "hares". Assume that you have 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 contain 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 a code to retrieve a word's canonical form and a Comparator that compares words by using their canonical forms. help please

Explanation / Answer

import java.util.*; public class Adding { public static void main(String[] args) { Scanner input = new Scanner(System.in); int num1, num2, sum; System.out.print("Enter first number: "); num1 = input.nextInt(); // reads first number from user System.out.print("Enter second number: "); num2 = input.nextInt(); // reads second number from user sum = num1 + num2; // Adds them up System.out.println("The sum of " + num1 + " and " + num2 + " is " + sum); // OR YOU CAN USE System.out.printf("The sum of %d and %d is %d", num1, num2, sum); } }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote