Write a program that does two string functions: capitalize the first word of a phrase, and reverse the letters of words in odd positions within the phrase. For this program it is acceptable to let punctuation be part of the word. Write a capitalizeWords() and a reverseOddWords() method and call them in a test program. Make certain to properly handle empty phrases, phrases with one and two words, and phrases with greater than two words. For example, if the original phrase were: Learning Java is fun! Java is powerful and easy to use The capitalized version would be: Learning Java Is Fun! Java Is Powerful And Easy To Use And with reversed odd words would be: gninraeL Java sI Fun! avaJ Is lufrewoP And ysaE To esU
Write a
For example, if the original phrase were:
Learning Java is fun! Java is powerful and easy to use
The capitalized version would be:
Learning Java Is Fun! Java Is Powerful And Easy To Use
And with reversed odd words would be:
gninraeL Java sI Fun! avaJ Is lufrewoP And ysaE To esU
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images