
Before Reading Instruction: Please Write In java! Pleasee add short comments not long. Keep Code neat and simple. Dont add any unnecesary code. Do as instructed. Instructions are below This line. Read Everything! __________________________________________________________________________________________________
You are going to write a program that uses a binary tree to translate morse code into characters. You may use the Java Libraries to solve this problem. We recommend using java.util.*
Morse code is a method used in telecommunication to encode text characters as standardized sequences of two different signal durations, called dots and dashes, or dits and dahs, respectively. Morse Code refers to a system for representing letters of the alphabet, numerals, and punctuation marks by an arrangement of dots, dashes, and spaces, known as the Morse Code Alphabet. A picture of the alphabet is shown below. In telecommunication a space is designated by “time units” between characters so for our purposes, we will designate a space with NULL.
Program Binary Tree
Create a binary tree to establish a morse-code table, and implement encode and decode methods.
Build the binary tree, by reading from the file morse.txt.
You will encode and decode messages by searching on THAT tree. Look at the morse-code alphabet image below with yellow background, and the image of the binary tree (what your binary tree should look like when you build it). Notice how if you search LEFT on the tree it registers a dot ? Notice how h translated to morse code moves left 4 times on the tree, therefore h is represented as 4 dots ….
Data
For your data you need letters and a Boolean (NULL), indicating that the node is empty, since not all nodes encode data. Here a sequence of dots " . " and dashes " - " are used to represent morse-code. Use spaces to separate morse-code 'letters'.
Read the morse-code data from a file called morse.txt . This file contains letters (lowercase), a space, and the morse code.
While our images all show capital letters for morse code and the binary tree, for simplicity you may assume that all letters are lower case only.
Class and Methods
You need to define a class, MorsecodeTree. This class should contain the following methods:
String encode method - takes a string of characters and encodes it as morse-code. Letters in either upper or lowercase get translated to morse, and the dot " . " and dash " - " pass through unchanged. Any other character is not passed to the output string. Use the space to separate individual morse code letters. Hint: you may want to do one that encodes one character. To accomplish all of this you need to search the tree.
String decode method - takes a string of space-separated morse-code letters and produces a string with the corresponding alphabetical letters. The produced string has all lowercase letters spaces between words. You can safely assume the input string contains only dot " . " and dash " - " and spaces. If the combinations of dot " . " and dash " - " for a given character is not valid, no corresponding character should be put on the output string. Hint: To accomplish all of this you need to search the tree.
Program Input / Output
Your program should allow the user to select either encode or decode message option. Then, the program will ask for the appropriate message string and print the appropriate corresponding result. The program should then return to the option to select either encode or decode messages.
If user selects option to encode a message, user enters an alphabetic string and system prints the morse-code message result.
If user selects option to decode a message, user enters a morse-code message and system prints the result translated into an alphabetic message.
Getting Started
- Review the Morse code alphabet and binary tree images below.
- Review below the morse.txt file which represents the letters of the alphabet that you will use to build your binary tree. Your program should read this data from a file to build the tree.
- Once you build your binary tree, it would have the form shown in the binary tree image thats attached.
- Allow users to select a message option (encode or decode) and have your program print the translated message out to the screen.
Morse.txt File:
*
e
i
s
h
NULL
NULL
v
NULL
NULL
u
f
NULL
NULL
NULL
a
r
l
NULL
NULL
NULL
w
p
NULL
NULL
j
NULL
NULL
t
n
d
b
NULL
NULL
x
NULL
NULL
k
c
NULL
NULL
y
NULL
NULL
m
g
z
NULL
NULL
q
NULL
NULL
o
NULL
NULL



Trending nowThis is a popular solution!
Step by stepSolved in 4 steps with 1 images

- Please help me write this Java code for this question I’m having troublesarrow_forwardPS: Please answer number 1 and 2 as they are all linked altogether with the subparts by following the instructions perfectly and not confusing. Write a Java Program with an intentional error in it. 1. Your program must include Loops and Arrays with a breakpoint 2. Once you have created your program, debug the application in eclipse to fix the error. a. Ensure that you take at least 3 screenshots of the debugging process and provide a brief explanation of the step. b. Ensure you use breakpoints and submit a snapshot labelling it. c. Submit all steps.arrow_forwardPS: Please answer number 1 and 2 as they are all linked altogether with the subparts by following the instructions wonderfully. Create a Java Program with an intentional error in it. 1. Your program must include Loops and Arrays with a breakpoint 2. Once you have created your program, debug the application in eclipse to fix the error. a. Ensure to have least 3 screenshots of the debugging process with a brief explanation of the step. b. Ensure the code use breakpoints with a snapshot labelling it. c. Submit all steps.arrow_forward
- True or False ___ 9. Java virtual machine is different for different platforms. ___ 10. Java statement ends with a column. ___ 11. Java program must use the class name as its file name. ___ 12. Logical errors are the same as the run time errors. ___ 13. Java byte code is a binary code.arrow_forwardimport java.util.Scanner ; //This program enables the user enters 10 int between -100 and 100 //then a menu is presented to the user to choose an operation to be //performed on the entered numbers. //operations: add all numbers and display their total //display the average of the numbers //find and display all negative numbers //find and display odd numbers //display all numbers in reverse order //display all 5 multiples public class OPonArrays { public static void main (String [] main) { int SIZE = 10; int [] nums= new int [SIZE]; Scanner KB = new Scanner(System.in); // populate the array for(int i = 0; i < 10; i++) { System.out.println("please enter a number between -100 and 100"); nums[i] = KB.nextInt(); } //display all elments for(int i = 0; i < 10; i++) { System .out.println(nums[i]); } fix the errorarrow_forwardWith no error Instructions The files provided in the code editor to the right contain syntax and/or logic errors. In each case, determine and fix the problem, remove all syntax and coding errors, and run the program to ensure it works properly. An example of the program is shown below: Enter a number >> 56 Enter a larger number >> 111 83.5 is halfway between 56 and 111 Task 1: The DebugSix4 class compiles without error. Task 2: The DebugSix4 program accepts user input and displays the correct output.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





