An anagram is direct word switch or word play, the result of rearranging the letters of...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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. 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.
Expert Answer:
Answer rating: 100% (QA)
Heres the Java code for the anagram detector Java import javautilHashMapimport javautilMap public class AnagramDetector public static void mainString ... View the full answer
Related Book For
Building Java Programs A Back To Basics Approach
ISBN: 9780135471944
5th Edition
Authors: Stuart Reges, Marty Stepp
Posted Date:
Students also viewed these programming questions
-
Briefly describe ASCII and Unicode and draw attention to any relationship between them. [3 marks] (b) Briefly explain what a Reader is in the context of reading characters from data. [3 marks] A...
-
answer the question clearly You are building a flight-control system for which a convincing safety case must be made. Would you assign the tasks of safety requirements engineering, test case...
-
The Sellinger Business School's Information Technology Service (ITS) is considering a new process to refurbish older computers in order to save on costs of buying new computers. The five steps to the...
-
Explain what is meant by the yield rate of interest for a bond issue. Discuss.
-
The comparative balance sheet of Navaria Inc. for December 31, 20Y3 and 20Y2, is as follows: The income statement for the year ended December 31, 20Y3, is as follows: Additional data obtained from an...
-
Fill in the Blank. In real-time frequency analysis, the signal is continuously analyzed over all the ___________ bands.
-
Identify the working capital accounts related to (a) Revenues recognized and deferred, (b) Cost of goods sold, (c) Employee salary and wages, and (d) Income tax expense. For each account, indicate...
-
write a paper introduction of IFRS adoption effect in germany on financial reporting quality
-
Discuss the role of cofactors and prosthetic groups in enzyme function. How do these molecules contribute to enzymatic activity, and what happens when they are deficient or absent ?
-
You are at a possible listing appointment with a new landlord when he questions your management commission fee and quotes a substantially less rate from your competitor. What communication skills...
-
(i) Why is the role of an HR Manager so important in an organization? (ii)What are the key functions within HR? (iii)How do HR Managers motivate their staff?
-
What are the main alternative actions or policies that might be followed in responding to the ethical issues in Terri Schiavo's case
-
You overhear two colleagues discussing whether to vote in favor of a change to your company's policy regarding in house dating. Mary proposed the change to the policy and Tom is against the change....
-
a description of how the supervisor should address the supervisee's knowledge and/or skill deficit (i.e., what should the supervisee have known or been able to do that he or she did not do that...
-
Explain why a firm with extra cash might choose to do a stock repurchase rather than begin a cash dividend program.
-
For each of the following reactions, express the equilibrium constant: a) H20 (I) H2 (g) + 02 (g) Ke = 1.0x107 b) Fe2 (g) 2F (g) Ke= 4.9 x 10-21 c) C (s) + O2 (g) d) H2 (g) + C2H4 (g) C2H6 (g) Ke =...
-
Would you want to work for a foreign-owned firm? Why or why not?
-
What is the impact of the Internet on international business? Which companies and which countries will gain as Internet usage increases throughout the world? Which will lose?
-
Which markets are more important to international businessesthe traditional markets of North America, the EU, and Japan, or the emerging markets? Defend your answer.
Study smarter with the SolutionInn App