Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Part 2 1. Write a method called lexLargest that takes a string object argument containing some text. Your method should return the lexicographical largest word
Part 2 1. Write a method called lexLargest that takes a string object argument containing some text. Your method should return the lexicographical largest word in theString object (that is, the one that would appear latest in the dictionary) String large = 1exLargest ("I am the very model of a modern major general"); System.out.println(large); / should print: very 2. Write a method called largestBy that takes a string object argument containing some text. Yourmethodshould return the largest-by-length word in the String object. In case of ties, return the first occurrence of the largest word. Note the return type is String. Example, String large large largestBy ("I am the very model of a modern major general"); System.out.println(large); /I should print genera.l 3. Optional Now, using above two methods, see if you can combine them in one single method and still produce the same outputs? NOTE: use an integer to determine which algorithm your code will execute, e.g., String largestByAction(String inputText, int action) If integer action is 1, then run first algorithm and if integer action is 2, then run the 2nd algorithm. Also, if the integer action is anything other than 1 or 2, return the empty string
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