Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write your code in the file WordCount.java . Your code should go into a method with the following signature. You may write your own main

Write your code in the file WordCount.java. Your code should go into a method with the following signature. You may write your own main method to test your code. Autolab will ignore your main method: public static int countWords ( String original, int maxLength ){}

Your method should count the number of words in the sentence that have have the same length or are less than maxLength (in letters). For example, if the maxLength length given is 4, your program should only count words that are at most 4 letters long.

Words will be separated by one or more spaces. Non-letter characters (spaces, punctuation, digits, etc.) may be present, but should not count towards the length of words.

Hint: write a method that counts the number of letters (and ignores punctuation) in a string that holds a single word without spaces. In your countWords method, break the input string up into words and send each one to your method.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Successful Keyword Searching Initiating Research On Popular Topics Using Electronic Databases

Authors: Randall MacDonald, Susan MacDonald

1st Edition

0313306761, 978-0313306761

More Books

Students also viewed these Databases questions

Question

Evaluating Group Performance?

Answered: 1 week ago