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
-
Problem 9 - 1 0 Present value [ LO 9 - 3 ] How much would you have to invest today to receive the following? ( Enter all answers as positive numbers. ) a . $ 1 2 , 5 0 0 in 7 years at 1 1 percent. (...
-
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...
-
Suppose that your company leases a valuable asset and you are a manager whose remuneration is partially tied to the company meeting a particular earnings target. How is your ability to meet the...
-
Information for two companies in the same industry, Patton Corporation and Sager Corporation, is presented here. Instructions Using the cash-based measures presented in this chapter, compare the (a)...
-
Statistical analysis of telephone calls A random sample of 50 long-distance phone calls was made by Crabbis Company in an effort to determine if restrictions should be placed on long distance...
-
Sendelbach Corporation is a U.S.-based organization with operations throughout the world. One of its subsidiaries is headquartered in Toronto. Although this wholly owned company operates primarily in...
-
find the area enclosed by the given curves y=2x-x^2,y=2x-4
-
Truss members supporting a roof are connected to a 26-mm-thick gusset plate by a 22 mm diameter pin as shown in the figure and photo. The two end plates on the truss members are each 14 mm thick. (a)...
-
Final account in construction project is an important document in project management process to show the final cost of a project that has been completed by the contractor. Discuss on what are the nece
-
You invest $ 2 0 0 per month for 4 0 years. How much will you have at the end of 4 0 years if your interest rate is 1 0 % ? Round your answer to the nearest whole dollar and do not use comma...
-
This is the part four of your Risk Management assignment. You will be looking at your business and typical contracts used in it. How to Proceed Using the business and Risk Management Template from...
-
It is expected that in exactly three years, a 12-month pure discount bond with a face value of $5,000 will sell for $4,900. If 4-year spot (zero) rates are 3.00% p.a., based on pure expectation...
-
Discuss the concept of thermodynamic stability in the context of equilibrium states, addressing both stable and metastable conditions and the role of free energy landscapes in determining system...
-
Discuss the role of advanced energy storage technologies, such as lithium-ion batteries and solid-state batteries, in enhancing the reliability and integration of renewable energy sources like solar...
-
High touch products refer to: Group of answer choices Products which are high quality and low priced Products which are handmade and hence represent a higher value Products whereby personal...
-
The following information is available for Partin Company: Sales $598,000 Sales Returns and Allowances 20,000 Cost of Goods Sold 398,000 Selling Expense 69,000 Administrative Expense 25,000 Interest...
-
The September 3, 2009, issue of BusinessWeek includes an article by Lindsey Gerdes entitled The Best Places to Launch a Career. It provides interesting information regarding the job opportunities for...
-
Presented below are selected financial statement items for Rowe Corporation for December 31, 2012. Inventory $ 55,000 Cash paid to purchase equipment $ 30,000 Cash paid to suppliers 154,000 Equipment...
-
Purpose: Identify summary information about companies. This information includes basic descriptions of the companys location, activities, industry, financial health, and financial performance....
Study smarter with the SolutionInn App