fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. Scanner in = new Scanner(System.in);
  13. String User=in.nextLine();
  14. Map<String, String> hm = new HashMap<String, String>();
  15. hm.put("a", ".-");
  16. hm.put("b", "-...");
  17. hm.put("c", "-.-.");
  18. hm.put("d", "-..");
  19. hm.put("e",".");
  20. hm.put("f","..-.");
  21. hm.put("g","--.");
  22. hm.put("h","....");
  23. hm.put("i","..");
  24. hm.put("j",".---");
  25. hm.put("k","-.-");
  26. hm.put("l",".-..");
  27. hm.put("m","--");
  28. hm.put("n","-.");
  29. hm.put("o","---");
  30. hm.put("p",".--.");
  31. hm.put("q","--.-");
  32. hm.put("r",".-.");
  33. hm.put("s","...");
  34. hm.put("t","-");
  35. hm.put("u","..-");
  36. hm.put("v","...-");
  37. hm.put("w",".--");
  38. hm.put("x","-..-");
  39. hm.put("y","-.--");
  40. hm.put("z","--..");
  41.  
  42. for (char letter : User.toCharArray()) {
  43. //System.out.println(letter);
  44. for (String key : hm.keySet()) {
  45. if (letter == key.charAt(0)) {
  46. System.out.print(hm.get(key));
  47. System.out.print(" ");
  48. }
  49. }
  50. }
  51. }
  52. }
Success #stdin #stdout 0.15s 321344KB
stdin
abcd
stdout
.- -... -.-. -..