TopCoder problem "CultureShock" used in SRM 216 (Division II Level One)



Problem Statement

    Bob and Doug have recently moved from Canada to the United States, and they are confused by this strange letter, "ZEE". They need your assistance. Given a String text, replace every occurrence of the word, "ZEE", with the word, "ZED", and return the result.



Note that if "ZEE" is just part of a larger word (for example, "ZEES"), it should not be altered.
 

Definition

    
Class:CultureShock
Method:translate
Parameters:String
Returns:String
Method signature:String translate(String text)
(be sure your method is public)
    
 

Constraints

-text will contain between 1 and 50 characters inclusive.
-Each character in text will either be a space (' '), or a capital letter ('A'-'Z').
-text will have precisely one space between consecutive words, and it will have no leading or trailing spaces.
 

Examples

0)
    
"THE TWENTY SIXTH LETTER OF THE ALPHABET IS ZEE"
Returns: "THE TWENTY SIXTH LETTER OF THE ALPHABET IS ZED"
There is precisely one occurrence of "ZEE" in this line of text, so it should be replaced with "ZED".
1)
    
"ZEE"
Returns: "ZED"
2)
    
"SPELLING IN ENGLISH IS EZEE"
Returns: "SPELLING IN ENGLISH IS EZEE"
The "ZEE" at the end of this line should not be altered since it is part of a larger word.
3)
    
"ZEE ZEE ZED ZEDS ZEE ZEES"
Returns: "ZED ZED ZED ZEDS ZED ZEES"

Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=2983

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=5862&pm=2983

Writer:

dgarthur

Testers:

PabloGilberto , lbackstrom , brett1479

Problem categories:

Simple Search, Iteration, String Parsing