Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ReplaceCheck
- {
- /**
- A method to replace letters as follows:
- the letter e becomes 3, the letter i becomes 1,
- the letter l becomes 7, and the letter o becomes 0.
- @param str a string
- @return the string with the characters replaced
- */
- public static String replace(String str)
- {
- String result = "";
- for(int i = 0; i < str.length(); i++)
- {
- switch(str.charAt(i))
- {
- case 'e':
- result += '3';
- break;
- case 'i':
- result += '1';
- break;
- case 'l':
- result += '7';
- break;
- case 'o':
- result += '0';
- break;
- default:
- result += str.charAt(i);
- break;
- }
- }
- return result;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement