Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA My require is showing below, please help me adjust my code to avoid , and . been recognized In this method I need to

JAVA
My require is showing below, please help me adjust my code to avoid "," and "." been recognized
image text in transcribed
image text in transcribed
image text in transcribed
In this method I need to seperate input from command line arguments to words and split in an array. However this method also recognize ',' and '. ' as a string. As the output below, in the "Largest word(s)" it recognize "blue." as a words, but it should be only "red" and "blue" as a word. How can I ignore the "," and "." when spliting words? Olic elass PhraseAnalyzert public static void main (String[l args) ( if (isvalidphrase(args)) f // Phrases are valid 1 public static boolean isValidphrase (String [] phrase) ( 1+x public static string[] getwords (String[] phrase) I String ] words = new String [0]; for (String arg : phrase) String [] argwords = arg.split (" ")|; words = Arrays. copyof (words, words. length + argwords. length) ; System.arraycopy (argwords, 0, words, words. 1ength - argwords.length, argwords. length) : 1 return words; 1 y public static String getSmallestWords (String[] words) ( sec public static String getLargestWords (String[] words) ( 1+k public static double getAverageWorldtength(String[] words) ( SUSQLAPTOP-SOMKDA2M MINGW64 /Project2/src java PhraseAnalyzer. java Roses are red, some roses are blue. smallest word(s): are argest word(s): Roses, roses, blue. Average word 7ength: 4.14 east frequently used letter(s): b, d, 1, m, u lost frequently used letter (s): e

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

Database Reliability Engineering Designing And Operating Resilient Database Systems

Authors: Laine Campbell, Charity Majors

1st Edition

978-1491925942

More Books

Students also viewed these Databases questions