Question: JAVA question a)Write a method called grabFirstToken that takes a single String parameter and returns a String value. This method should return a String that

JAVA question

a)Write a method called grabFirstToken that takes a single String parameter and returns a String value. This method should return a String that is equivalent to a substring of the String parameter up to the first whitespace character (either space, tab, or newline). Your method should look for the first whitespace character in the parameter String, and return the substring up to (but not including) this first whitespace character. For example, if called with a parameter of Three blind mice your method should return: Three

b)Write a method called shuffleNames that takes an array of Strings as a parameter and returns a String value. This method should treat the Strings given by the parameter array as names, and re-combine them so that they will print out with each name in a different column instead of on a different line. The names should appear in the same order, left-to-right, as the order they are given in the parameter array. Your method should return a String that will contain each name in a different vertical column when printed, with spaces included to accommodate names of different lengths For example, if the names given in the parameter array were (in order) Athena, Apollo, Hera, Hermes, and Winston, then your method would return a String value that looked like this when printed: AAHHZW tpeeei horrun elamss nl e t ao s o n

c)Write a main method that prompts the user for six names and collects these in an array of Strings. If the user gives multiple names, or any String containing multiple words separated by whitespace, then you should only store the first word. That is, you should consider the users input, and only store their first word (up to the first occurrence of whitespace) as the inputted name. For example, if the user were to give Harold Winston after being prompted for a name, then you should only store Harold. Use the method from part (b) to print out the result of shuffling these names into vertical columns.

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!