Last active
March 29, 2017 18:59
-
-
Save DimasInchidi/3cccf109d9978f4efe7d331ccc3df222 to your computer and use it in GitHub Desktop.
Jawaban pertanyaan https://web.facebook.com/groups/JAVA.Programmer.Indonesia/permalink/10155224194696383/
This file contains 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
class Replace { | |
public static void main (String[] args) throws java.lang.Exception { | |
Map<String, String> map = new HashMap<String, String>(); | |
//n?kfv-=xa. | |
map.put("a", "n"); | |
map.put("b", "?"); | |
map.put("c", "k"); | |
map.put("d", "f"); | |
map.put("e", "v"); | |
map.put("f", "-"); | |
map.put("g", "="); | |
map.put("h", "x"); | |
map.put("i", "a"); | |
map.put("j", "."); | |
java.util.Scanner reader = new java.util.Scanner(System.in); | |
System.out.print("Masukan pesan: "); | |
String pesan = reader.nextLine().replaceAll("[^abcdefghij]", "*"); | |
for (Map.Entry<String, String> entry : map.entrySet()) { | |
pesan = pesan.replace(entry.getKey(), entry.getValue()); | |
} | |
System.out.print(pesan); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment