Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Part 0 3 : Get Acronym Method Description getAcronym ( String ) : String A public static method that when called and passed a `
Part : Get Acronym
Method Description
getAcronymString : String A public static method that when called and passed a String must compute and return a String value that contains just the capitalized first letter of each word.
Note: the arguments to this method will always be a String containing one or more words, and the words will always be separated by a single space character, and a space character will always be followed by another word.
Hints:
The indexOf method can be very helpful for finding things like space characters in a String
Java has an overloaded indexOf method with takes an extra int argument indicating where to start a search in a String
Java also has an lastIndexOf method, which searches a String starting at the end.
The substring method can be very helpful for extracting one or more characters from a String
You may need to write some code to make decisions based on whether the input has one just first two first and last or three first middle, and last names.
A loop will definitely be useful.
It can be helpful to know and understand the difference between the Scanner methods next and nextLine
The Java String class include a method named toUpperCase that may also be useful.
doGetAcronymScanner Partially provided in template and called by the menu, which provides a Scanner object. Remove the placeholder message.
Then implement the following functionality:
prompt the user to enter some words
collect and store the user's input in a String variable
call the getAcronym method, passing the user's input as an argument
store the value returned by the getAcronym method in another String variable
Display the name and acronym as shown in the examples below
Here are some examples showing what the value returned by your getAcronym method should be for different argument values:
Example
Enter some words : fear of missing out
Acronym for fear of missing out : FOMO
Example
Enter some words : self contained underwater breathing apparatus
Acronym for self contained underwater breathing apparatus : SCUBA
For the given inputs, make sure that your program output looks exactly like the example above including spelling, capitalization, punctuation, spaces, and decimal points
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