80.9k views
4 votes
Given a phrase with one or more words, capitalize the first letter of each word and make the remaining letters all lowercase.

Example:

initialCap("hello karel") --> "Hello Karel"
initialCap("JAVA in hIgh SchOOl") --> "Java In High School"

This is in Java.

1 Answer

3 votes

Answer:

Is provided in the attached screenshot!

Step-by-step explanation:

Steps taken:

1) Take input sentence and make it all lowercase

2) Split input sentence into separate words and store in an array

3) Go through each word and replace the first letter with the capital version of the letter

4) Combine each word back into a sentence.

5) Return the sentence

Given a phrase with one or more words, capitalize the first letter of each word and-example-1
User Martin Fehrs
by
7.5k points