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.
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
"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"."ZEE"
Returns: "ZED"
"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."ZEE ZEE ZED ZEDS ZEE ZEES"
Returns: "ZED ZED ZED ZEDS ZED ZEES"