Guys, I have this question: I want to create a Morzian encoder using HashMap. I entered the entire Latin alphabet, made the text input function, but I do not know how to make the program read the text entered by the user and translate it into Morse. I assume that you need to use the if statement, but I do not know how. PS I'm new. Here is the code:
package teach; import java.util.Map; import java.util.HashMap; import java.util.Scanner; public class Teach { public static void main(String[] args) { Scanner in = new Scanner(System.in); String User=in.nextLine(); Map<String, String> hm = new HashMap<String, String>(); hm.put("a", ".-"); hm.put("b", "-..."); hm.put("c", "-.-."); hm.put("d", "-.."); hm.put("e","."); hm.put("f","..-."); hm.put("g","--."); hm.put("h","...."); hm.put("i",".."); hm.put("j",".---"); hm.put("k","-.-"); hm.put("l",".-.."); hm.put("m","--"); hm.put("n","-."); hm.put("o","---"); hm.put("p",".--."); hm.put("q","--.-"); hm.put("r",".-."); hm.put("s","..."); hm.put("t","-"); hm.put("u","..-"); hm.put("v","...-"); hm.put("w",".--"); hm.put("x","-..-"); hm.put("y","-.--"); hm.put("z","--.."); for (String key : hm.keySet()) { } }