The map will map characters to integers. Your method would be called by the following program: import java.util. Map; import java.util.List; import java.util.ArrayList; import java.util.Collections; public class Main public static void main(String () args) { Map count = MakeMap.countLetters ("hello"); List letters = new ArrayList(count.keySet ()); Collections.sort(letters); for(Character letter : letters) System.out.println("There are " + count.get (letter) + " of the letter " + letter + "); When run, this will print out the frequency of occurrence of each letter. $ java Main There are 1 of the letter 'e' There are 1 of the letter 'h' There are 2 of the letter 'l' There are 1 of the letter 'o' Note that each letter in "hello" occurs once except for the I' which occurs twice. To summarize, you write the MakeMap class with a static method countLetters(). This takes a word as a parameter. You need to create a map which maps each letter of the word to how often that letter occurs.
The map will map characters to integers. Your method would be called by the following program: import java.util. Map; import java.util.List; import java.util.ArrayList; import java.util.Collections; public class Main public static void main(String () args) { Map count = MakeMap.countLetters ("hello"); List letters = new ArrayList(count.keySet ()); Collections.sort(letters); for(Character letter : letters) System.out.println("There are " + count.get (letter) + " of the letter " + letter + "); When run, this will print out the frequency of occurrence of each letter. $ java Main There are 1 of the letter 'e' There are 1 of the letter 'h' There are 2 of the letter 'l' There are 1 of the letter 'o' Note that each letter in "hello" occurs once except for the I' which occurs twice. To summarize, you write the MakeMap class with a static method countLetters(). This takes a word as a parameter. You need to create a map which maps each letter of the word to how often that letter occurs.
Chapter9: Advanced Array Concepts
Section: Chapter Questions
Problem 19RQ
Related questions
Question
Can someone help me with the following java program please
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps with 1 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT