Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

The letters of the alphabet A through Z can be represented in Morse code. Each letter is represented by a combination of up to four dots and/or dashes, as shown below. Use Java to write and run a console-window program that can convert an English message into Morse code or a Morse code message into English. The program must satisfy the following requirements:

Create a class called MorseCode that has at least the following two methods: (1) a method with signature toMorseCode(char) that accepts a single capital letter from the English alphabet and returns an array of 4 characters representing the Morse code equivalent of that letter, and (2) a method with signature fromMorseCode(char[4]) that accepts an array of four Morse code characters (each either a dot, a dash, or space) and returns the English letter equivalent. The MorseCode class will have two static variables. The first, of type char[], will store the 26 letters of the alphabet. The second, of type char[][], will store the Morse code for each of the 26 letters of the alphabet.

Create a driver class called TestMorseCode. At a minimum

    When the program runs, it should first print its name
    The program should next ask the user first whether the original input will be in English or in Morse code
    Based on the answer, the program will ask the user to enter either a phrase in English, or the Morse code for a phrase
    If the user is entering an English phrase, a carriage return will indicate the end of the phrase. If the user is entering Morse code, any character other than . (dot), - (dash), or space will indicate the end of the phrase
    The program will then print the result after conversion
    Your source code must conform to good programming style, with all comments in Javadoc format.

Here is an example of its execution:

    Morse Code Conversion Program.
    This program reads a phrase in English (or Morse code) and prints
    its equivalent in Morse code (or English).

    If your original message is in English, please enter an E.  If it
    is in Morse code, please enter an M.  Enter any other character to
    quit: E

    Please enter a phrase in English, followed by a carriage return:
    PARTY ON

    The Morse code for your phrase is:
    .--..-  .-. -   -.--    --- -. 

    Goodbye.


    Morse Code Conversion Program.
    This program reads a phrase in English (or Morse code) and prints
    its equivalent in Morse code (or English).

    If your original message is in English, please enter an E.  If it
    is in Morse code, please enter an M.  Enter any other character to
    quit: M

    Please enter a phrase in Morse code, followed by a carriage return:
    .....   .-...-..---

    Your phrase in English is:
    HELLO

    Goodbye.

Conversion Table:

  A .-      H ....    O ---     V ...-
  B -...    I ..      P .--.    W .--
  C -.-.    J .---    Q --.-    X -..-
  D -..     K -.-     R .-.     Y -.--
  E .       L .-..    S ...     Z --..
  F ..-.    M --      T -
  G --.     N -.      U ..-

Java, Programming

  • Category:- Java
  • Reference No.:- M9456131

Have any Question?


Related Questions in Java

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Fundamentals of operating systems and java

Fundamentals of Operating Systems and Java Programming Purpose of the assessment (with ULO Mapping) This assignment assesses the following Unit Learning Outcomes; students should be able to demonstrate their achievements ...

Applied software engineering assignment 1 -learning

Applied Software Engineering Assignment 1 - Learning outcomes - 1. Understand the notion of software engineering and why it is important. 2. Analyse the risk factors associated with phases of the software development lif ...

Assessment database and multithread programmingtasktask 1

Assessment: Database and Multithread Programming Task Task 1: Grade Processing University grading system maintains a database called "GradeProcessing" that contains number of tables to store, retrieve and manipulate stud ...

Retail price calculatorwrite a java program that asks the

Retail Price Calculator Write a JAVA program that asks the user to enter an item's wholesale cost and its markup percentage. It should then display the item's retail price. For example: (If an item's wholesale cost is 5. ...

Operating systems assignment -problem 1 sharing the bridgea

Operating Systems Assignment - Problem 1: Sharing the Bridge A new single lane bridge is constructed to connect the North Island of New Zealand to the South Island of New Zealand. Farmers from each island use the bridge ...

Question slideshows or carousels are very popular in

Question : Slideshows (or carousels) are very popular in websites. They allow web developers to display news or images on the website in limited space. In this code challenge, you are required to complete the JavaScript ...

Part a specification - robot simulationpart a

PART A Specification - Robot Simulation PART A Requirements To complete this assignment you will use the supplied eclipse project Robot P1/. It is already set up to execute a simple arm movement loop which you will build ...

Assessment database and multithread programmingtasktask 1

Assessment: Database and Multithread Programming Task Task 1: Grade Processing University grading system maintains a database called "GradeProcessing" that contains number of tables to store, retrieve and manipulate stud ...

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As