Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Morse {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String morse[] = {".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..",
- "--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--..",
- "|",".---","..---","...--","....-",".....","-....","--...","---..","----.","-----"};
- char Alphabet [] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q',
- 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', ' '};
- String input = scanner.nextLine();
- String[] text = input.split("\\s+");
- String newText = "";
- for (int i = 0; i < text.length; i ++){
- for (int j = 0; j < morse.length; j ++){
- if (text[i] == morse[j]){
- newText+= Alphabet[j];
- }
- }
- }
- System.out.println(newText);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement