Question: 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

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!