Answered step by step
Verified Expert Solution
Question
1 Approved Answer
An anagram is direct word switch or word play, the result of rearranging the letters of a word or phrase to produce a new
An anagram is direct word switch or word play, the result of rearranging the letters of a word or phrase to produce a new word or phrase, using all the original letters exactly once; for example, you can rearrange the letters of the word cinema to produce iceman. Your task is to write a simple anagram detector: it compares two phrases and reports whether or not they use the same number of the same letters (ignoring case and any non-letter symbols). The detector will work by checking if both phrases use the same number of eachvietter: 1. The count Letters method counts how many times each letter occurs in a word and returns an array of integers representing this tally. The oth element represents how many a or A's were found in the word, the 1st element represents how many b/B's,... and the 25th element how many z/Z's. All other symbols are ignored in the resulting array. 2. The sameCounts method compares two integer arrays and returns true only if they have the same contents, including their sizes and values for each element. Note: you are not allowed to use Arrays.equals, or equivalent, to implement this method. Your main method should prompt the user for two phrases, then report whether or not they are anagrams; for example... Enter phrase 1: cinema Enter phrase 2: iceman These phrases are anagrams. Enter phrase 1: cinema Enter phrase 2: snowman These phrases are not anagrams. Enter phrase 1: Anagrams! Enter phrase 2: Ars Magna These phrases are anagrams.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Heres the Java code for the anagram detector Java import javautilHashMapimport javautilMap public class AnagramDetector public static void mainString ...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