Created
September 10, 2012 05:56
-
-
Save chintanparikh/3689129 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
/** | |
* LeetTranslator translates text into leetspeak | |
*/ | |
public class LeetTranslator { | |
public static void main(String[] args) { | |
// Create the mapping between normal characters and leet speak | |
Map<Character, Character> leetMap = new HashMap<Character, Character>(); | |
leetMap.put('a', '@'); | |
leetMap.put('e', '3'); | |
leetMap.put('i', '1'); | |
leetMap.put('s', '5'); | |
leetMap.put('o', '0'); | |
Scanner scan = new Scanner(System.in); | |
System.out.print("Enter text to translate: "); | |
String normalInput = scan.nextLine(); | |
String output = normalInput; | |
Iterator leetIterator = leetMap.keySet().iterator(); | |
while(leetIterator.hasNext()) { | |
Character key = (Character)leetInterator.next(); | |
output = output.replace(key, leetMap.get(key)); | |
} | |
System.out.println(output); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment