You can use a map where the keys are the integer length and


A passage of text is rated for difficulty by the length of the words it contains. You are to complete the class WordLengthFinder to group words by their length.

You are given a string. Create a Scanner to process the String. You are to print the words with the shortest words first. Within words of the same length, you are to print the words alphabetically.

You can use a Map where the keys are the Integer length and the values are the Set of the words of that length. This is similar to hw 17.

You can print the Set mySet like this: System.out.println(mySet);

For the string "Mary had a little lamb", the output would look like this

[a] [had] [Mary, lamb] [little]

In order to get words without following punctuation, create a scanner for the String and set the delimiter to use: scan.useDelimiter("[^A-Za-z0-9]+");

Code check will run your program more than once. Note that the second string is fairly long and you will have to scroll right to see expected and actual output.

----------------------------------------------------

Complete the following file:

WordLengthFinder.java

import java.util.TreeSet;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeMap;
public class WordLengthFinder
{
public static void main(String[] args)
{
String passage = "mary had a little lamb";
}

}

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: You can use a map where the keys are the integer length and
Reference No:- TGS02885034

Expected delivery within 24 Hours