Question: In a java program Need to find the purpose of this application have to create an application which is able to translate between back and
In a java program Need to find the purpose of this application have to create an application which is able to translate between back and forth between English letters A-Z and numbers 0-9 and Morse code dots . and dashes -. The user will be prompted to enter something to translate. The user may enter either English or Morse code. The application will then analyze what the user entered to try and figure out if the user entered English or Morse code. If the analysis determines the user entered something in English, it will then translate it into Morse code. If the analysis determines the user entered something in Morse code, it will then translate it into English. At any time, the user may enter -1 to exit the application.
HINT: Morse code is only dots . Dashes - and spaces . If the user input contains these 3 characters and only these 3 characters, its Morse code. Otherwise, assume its English.
This is what I have so far :
main.java:
package me
import java.util.Scanner;
/** * */ public class Main {
/** * @param args the command line arguments */ public static void main(String[] args) { System.out.printf("Welcome to translator! "); Scanner scanner = new Scanner(System.in); while (true) { System.out.printf("Enter text to translate (-1 to exit): "); String translateMe = scanner.nextLine();
if ("-1".equals(translateMe)) { break; } Translator translator = TranslatorFactory.getInstance(translateMe);
if (translator == null) { System.out.printf("%nUnable to determine the language%n%n"); } else { System.out.printf("%nDetected language: %s%n%n", translator.getLanguage()); System.out.printf("%s%n%n", translator.translate(translateMe)); } } System.out.printf(" Good bye! "); } }
package me
import java.util.ArrayList; import java.util.Arrays;
/** * */ public class Primer { private static ArrayList
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
