TopcoderArchiveVisit Topcoder
SRM1 Sep 2004
SRM 210

TitleString

Problem statement, definition, constraints, and public examples.

Problem Statement

A common word-processing task is capitalizing the first letter of each word in a title. Write a class TitleString with a method toFirstUpperCase that takes a String title containing lowercase words separated by one or more space characters and returns a String that is identical to title except with the first character of each word capitalized.

Definition

Class:
TitleString
Method:
toFirstUpperCase
Parameters:
String
Returns:
String
Method signature:
String toFirstUpperCase(String title)
(be sure your method is public)

Notes

  • title may have leading or trailing spaces.

Constraints

  • title will contain between 0 and 50 characters, inclusive.
  • Each character of title will either be a space or a lowercase letter ('a' to 'z').

Examples

  1. "introduction to algorithms"
    Returns: "Introduction To Algorithms"
  2. "more than  one   space    between     words"
    Returns: "More Than  One   Space    Between     Words"
  3. "  lord of the rings   the fellowship of the ring  "
    Returns: "  Lord Of The Rings   The Fellowship Of The Ring  "
  4. "  "
    Returns: "  "
  5. "i"
    Returns: "I"
  6. "the king and i"
    Returns: "The King And I"
  7. ""
    Returns: ""
Back to all problems