Answered step by step
Verified Expert Solution
Question
1 Approved Answer
JAVA In this boolean method I want to detect if the input from command line args are pure letters and two symbols , and .
JAVA
Search View Encoding Language Settings Tools Macro Run Plugins Window ? Anslyzer. java x import java.util.*; //import java util 7/ public class PhraseAnalyzerf / public static void main (String [] args) f 1 public static boolean isValidPhrase (String[] phrase) f for (String arg : phrase)f for (char c : arg. tochararray ()) f if (ICharacter. isLetter (c) as c!=,, s ct= sa tCharacter. iswhitespace (c)) I return false; 1// if not letter 1 /1 for al1 char in array 1 1/ for all elements in input array return true: 1 public static String[] getwords (String[] phrase) f 1 Public static string get.Smallestwords (String[] words) ( 16 public static String getLargestWords (String[] words) I I.. public static double getAverageWorldtength (Stringt) words) ( 1+x public static int [] getLetterTally(String[] words) t ASSUS@LAPTOP-SOMKDA2M MINGW64 /Project2/src $ java PhraseAnalyzer.java He7lo.World Sma77est word(s): He710, wor.7d Largest word(s): He17o, world Average word length: 5.00 Least frequently used letter(s):d, e, h, r,w Most frequently used letter(s):1 ASUS@LAPTOP-SOMKDAZM MINGW64 /Project2/src \$ java PhraseAna7yzer.java abc "t def Smallest word(s): abc, def Largest word(s): abc, def Average word length: 3.00 Least frequently used 7etter(s): a,b,c,d,e,f Most frequently used letter (s):a,b,c,d, e, f In this boolean method I want to detect if the input from command line args are pure letters and two symbols "," and "."
For output below, the command line args:
(abc "" def) and (Hello.World) are both detected as true but it should be false.
I suppose the period should add a space after it or it will return false, and for "" I have no idea of how to detect it and return false.
Please help me adjust my code to get rid of this problem.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started