Question: Problem Description and Given Info Write a public static method named nameToInitials that will take a single argument of type String and will return a

Problem Description and Given Info Write a public static method named nameToInitials that will take a single argument of type String and will return a String. When called, and passed a name, this method must compute and return a String value with the initials for the given name. Here are some examples showing what the value returned by your nameToInitials method should be for different argument values: nameToInitials ("Bob Allen Smith") should return the String value "B. A. S." nameToInitials ("Bob Smith") should return the String value "B. S." nameToInitials ("Bob") should return the String value "B." Note that the argument to this method may be a String containing just a first name (i.e. "Bob"), just first name and last name (i.e. "Bob Smith"), or the first name and middle name and last name (i.e. "Bob Allen Smith"). You must also write a small program in the main method that will: 1. prompt the user to enter a name 2. collect and store the user's input in a String variable 3. call the name ToInitials method, passing the user's input as an argument 4. store the value returned by the nameToInitials method in another String variable 5. Display the name and initials as shown in the examples below Example 1 Enter name : Bob Allen Smith Initials for Bob Allen Smith : B. A. S. Example 2 Enter name : Bob Smith Initials for Bob Smith : B. S
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
