What I need is a program that can take in a sentence and translate it to morse c
ID: 3533239 • Letter: W
Question
What I need is a program that can take in a sentence and translate it to morse code. The program needs to meet the requirements below. The program needs to display the original sentence entered and the morse equivalent. i need two files a driver class and a utility class(in the requirements below).
Program Description: A Java program is to be created to produce Morse code. The Morse code assigns a
series of dots and dashes to each letter of the alphabet, each digit, and a few special characters (such as
period, comma, colon, and semicolon). In sound-oriented systems, the dot represents a short sound and the
dash represents a long sound. Separation between words is indicated by a space, or, quite simply, the
absence of a dot or dash. In a sound-oriented system, a space is indicated by a short period of time during
which no sound is transmitted. The international version of the Morse code is stored in the data file Morse.txt.
To process the program, the Morse code data file (Morse.txt) should be read and stored in memory for fast
access to the code. Each letter of the alphabet has a Morse code equivalent. After the code table is stored, the
user should be prompted for an English language sentence to be entered from the keyboard. This sentence
should be encoded into Morse and displayed. One blank should be used to separate each Morse-coded letter
and three blanks should be used to separate each Morse-coded word. The user should be allowed to continue
with the process of entering a sentence and having it encoded until a sentinel value (0) is received.
Input: The letters and their equivalents are stored in a data file named Morse.txt. Input will consist of the
Morse.txt file and well as the sentences entered from the keyboard. The data file should be read and loaded
into memory at the beginning of the program before the sentences can be read and encoded. Each line of the
data file contains the letter of the alphabet followed by the code equivalent. The data file should be read and
stored in an array for fast and easy access during the program duration. When a sentence is read from the
keyboard, it can be translated from the data stored from the Morse code file.
Output: Output will consist of the display of the original sentence and it Morse code equivalent.
Requirements:
Explanation / Answer
please rate as promised still don't know what you mean by a utility class import java.util.*; import java.io.*; public class MorseCodeDriver {public static void main(String[] args)throws FileNotFoundException {Scanner in=new Scanner(new File("Morse.txt")); Scanner kb=new Scanner(System.in); int i,j,count=0; char c; String sentence,output=""; char[] letnum=new char [50]; String[] morse=new String[50]; while(in.hasNext()) //read into 2arrays, changing all letters to uppercase {letnum[count]=Character.toUpperCase(in.next().charAt(0)); morse[count]=in.next(); count++; //count how many letters there are } System.out.print("Enter a sentence to convert: "); sentence=kb.nextLine(); for(i=0;i
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.