Problem Statement
An online registration system must check that the registrants' user names are
unique. The user names are allowed to contain numbers, capital and lowercase
letters, and spaces. However, the system must be made so that the normalized
forms of all user names are unique.
The normalized form of a user name is the form in which all spaces are removed and all capital letters are converted to lower case.
Thus the user names "username" and "Us Er Na Me" do not have unique normalized forms.
You are to write a class Normalizer which contains a method normalize. The method takes a String that is a user name as a parameter and returns the normalized form of the user name.
The normalized form of a user name is the form in which all spaces are removed and all capital letters are converted to lower case.
Thus the user names "username" and "Us Er Na Me" do not have unique normalized forms.
You are to write a class Normalizer which contains a method normalize. The method takes a String that is a user name as a parameter and returns the normalized form of the user name.
Definition
- Class:
- Normalizer
- Method:
- normalize
- Parameters:
- String
- Returns:
- String
- Method signature:
- String normalize(String userName)
- (be sure your method is public)
Constraints
- userName contains between 1 and 50 characters, inclusive.
- userName contains at least 1 non-space character.
- userName contains lowercase and capital letters, digits, and spaces (a-z, A-Z, 0-9).
Examples
"username"
Returns: "username"
"Us Er Na Me"
Returns: "username"
"HI133"
Returns: "hi133"
" helloOoOo"
Returns: "hellooooo"
"a"
Returns: "a"
" 1 "
Returns: "1"