Create a scanner to process the string

Assignment Help Computer Engineering
Reference no: EM132091577

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";
}

}

Reference no: EM132091577

Questions Cloud

Primary difficulties associated with a middle-aged person : What do you think are some of the primary difficulties associated with a middle-aged person?
Describe appropriate selectional restrictions on the verbs : Cluster these senses using the definitions of homonymy and polysemy given in chapter 19 (Speech and Language Processing -Jurafsky Martin).
Create a user friendly gui app using the code parameters : Display a message dialog similar to the one shown in listing 2.12, but the message must pertain to VendingChange and not ChangeMaker.
Elevations of the great lakes in vectors : Pascal allows the use of enumerated types as index types.In the above definitions we stored the areas and elevations.
Create a scanner to process the string : 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.
What is the average case time complexity for linear search : What is the average case time complexity for linear search on a sorted array? Explain (and/or draw a diagram).
Primary objective of statistical process control : Describe the primary objective of statistical process control.
Why is it important for operations managers : Why is it important for operations managers to understand the local culture and practices of the countries
Hospitality industry has such a high turnover rate : What are the 3 biggest reasons that the hospitality industry has such a high turnover rate?

Reviews

Write a Review

Computer Engineering Questions & Answers

  How do approach collaborate to get to a common design

Which is more important, getting the overall structure right, or capturing the details for each layer? If the approach is to use three separate people, how do they collaborate to get to a common design and understanding?

  Draw gantt chart that shows completion time for each process

Draw a Gantt chart that shows the completion times for each process using first-come, first-served CPU scheduling.

  What implications does queues have for the mach scheduler

Each of the global run queues has a single mutex for locking it. What implications does this have for the Mach scheduler?

  Create a homework class with fields for the class name

Create a Homework class with fields for the class name, the assignment (for example, "read chapter 1"), and the number of minutes predicted.

  Calculate is which step of planning a database

Which of the following is not one of the database objects present in the Access database window.

  Describe in brief the type of test program you would need

Describe in brief the type of test program you would need to run on the system. and the type of measurements you would need to make.

  Create an app called blogs in the project

Create an app called blogs in the project, with a model called Blog-Post. The model should have fields like title, text, and date_added.

  Creating a program is important almost equally important is

creating a program is important. almost equally important is tracking down errors in the program. this process is

  Create a sitemap for site defining its basic information

Each student will write a 5 page paper, which will take 3 websites and/or social media sites/channels and critically analyze them for. Create a sitemap for each site defining its basic information architecture.

  Analyze source code and develop comprehensive unit test

Analyze source code and develop comprehensive unit test suites. Operate CASE software to document the design of a piece of software.

  What is the worst-case delay for acknowledging an interrupt

What is the worst-case delay for acknowledging an interrupt

  Define the terms adjacent path cycle and connected

Define the terms adjacent, path, cycle, and connected. What does it mean for a directed graph to be strongly connected? Weakly connected?

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd