Starting Out with Java: Early Objects (6th Edition)
Starting Out with Java: Early Objects (6th Edition)
6th Edition
ISBN: 9780134462011
Author: Tony Gaddis
Publisher: PEARSON
Question
Book Icon
Chapter 8, Problem 16PC
Program Plan Intro

Morse Code Converter

Program Plan:

The detail of “MorseCodeConverter” class is shown below:

  • In the “main()” method,
    • Declare the variable.
    • Create an object for Scanner class.
    • Read the string input from the user.
    • Create an object for Morse object to invoke parameterized constructor.
    • Call the getMorseCode() method to display the Morse code.

The detail of “Morse” class is shown below:

  • Declare the required variables.
  • In the “Morse()” parameterized constructor,
    • Declare and initialize the required variables.
    • The while loop executes until the “index” is less than length of input. If yes,
      • Get the morse code for character and then append it into “mcode” with newline.
      • Increment “index” by “1”.
  • In the “toMorse()” method,
    • Declare the variable.
    • The while loop executes until the find character in array. If yes, increment “index” by “1”.
    • Check whether “index” is greater than or equal to “NUM_CHARS”. If yes, set the value as character was not found.
    • Otherwise, get the morse code.
    • Return the morse value.
  • In the “getOriginal()” method,
    • Return the original string.
  • In the “getOriginal()” method,
    • Return the converted morsecode character.

Blurred answer
Students have asked these similar questions
4. Morse Code Converter Morse code is a code where each letter of the English alphabet, each digit, and vario punctuation characters are represented by a series of dots and dashes. Table 8-4 shows pe of the code. Write a program that asks the user to enter a string, then converts that string to Morse code Table 8-4 Morse code Character Code Character Code Character Code Character Code space space 6. comma H. R period 8. I question mark 6. J T. 0. A K 1 W 3 E 4
Morse code is a code where each letter of the English alphabet, each digit, and various punctuation characters are represented by a series of dots and dashes. Table 8-4 shows part of the code. Write a program that asks the user to enter a string, and then converts that string to Morse code. 366 Chapter 8 More About Strings Table 8-4 Morse code Character Code Character Code Character Code Character Code space space 6 – . . . . G – – . Q – – . – comma – – . . – – 7 – – . . . H . . . . R . – . period . – . – . – 8 – – – . . I . . S . . . question mark . . – – . . 9 – – – – . J . – – – T – 0 – – – – – A . – K – . – U . . – 1 . – – – – B – . . . L . – . . V . . . – 2 . . – – – C – . – . M – – W . – – 3 . . . – – D – . . N – . X – . . – 4 . . . . – E . O – – – Y – . – 5 . . . . . F . . – . P . – – . Z – – . . Gaddis Tony. Starting Out with Python (2-downloads) (p. 366). Pearson Education. Kindle Edition.
Lab Activity for the students: Exercise 5: Write a program that asks the user to input a letter. The program finds and prints if the letter is uppercase or lowercase. Then, the program asks the user to input a string and get a three-character substring from the beginning of the string. (1 Mark ) Example : If the inputs are 'y' and "Community". Then, the program will print: y is lowercase The substring is: Com

Chapter 8 Solutions

Starting Out with Java: Early Objects (6th Edition)

Ch. 8.3 - Prob. 8.11CPCh. 8.3 - Prob. 8.12CPCh. 8.3 - Prob. 8.13CPCh. 8.3 - Look at the following code: String str1 = To be,...Ch. 8.3 - Prob. 8.15CPCh. 8.3 - Assume that a program has the following...Ch. 8.4 - Prob. 8.17CPCh. 8.4 - Prob. 8.18CPCh. 8.4 - Prob. 8.19CPCh. 8.4 - Prob. 8.20CPCh. 8.4 - Prob. 8.21CPCh. 8.4 - Prob. 8.22CPCh. 8.4 - Prob. 8.23CPCh. 8.4 - Prob. 8.24CPCh. 8.5 - Prob. 8.25CPCh. 8.5 - Prob. 8.26CPCh. 8.5 - Prob. 8.27CPCh. 8.6 - Prob. 8.29CPCh. 8.6 - Prob. 8.30CPCh. 8.6 - Prob. 8.31CPCh. 8.6 - Prob. 8.32CPCh. 8 - The isDigit, isLetter, and isLetterOrDigit methods...Ch. 8 - Prob. 2MCCh. 8 - The startsWith, endsWith, and regionMatches...Ch. 8 - The indexOf and lastIndexOf methods are members of...Ch. 8 - Prob. 5MCCh. 8 - Prob. 6MCCh. 8 - Prob. 7MCCh. 8 - Prob. 8MCCh. 8 - Prob. 9MCCh. 8 - Prob. 10MCCh. 8 - To delete a specific character in a StringBuilder...Ch. 8 - Prob. 12MCCh. 8 - Prob. 13MCCh. 8 - Prob. 14MCCh. 8 - These static final variables are members of the...Ch. 8 - Prob. 16TFCh. 8 - Prob. 17TFCh. 8 - True or False: If toLowerCase methods argument is...Ch. 8 - True or False: The startsWith and endsWith methods...Ch. 8 - True or False: There are two versions of the...Ch. 8 - Prob. 21TFCh. 8 - Prob. 22TFCh. 8 - Prob. 23TFCh. 8 - Prob. 24TFCh. 8 - Prob. 25TFCh. 8 - int number = 99; String str; // Convert number to...Ch. 8 - Prob. 2FTECh. 8 - Prob. 3FTECh. 8 - Prob. 4FTECh. 8 - Prob. 5FTECh. 8 - The following if statement determines whether...Ch. 8 - Write a loop that counts the number of space...Ch. 8 - Prob. 3AWCh. 8 - Prob. 4AWCh. 8 - Prob. 5AWCh. 8 - Modify the method you wrote for Algorithm...Ch. 8 - Prob. 7AWCh. 8 - Look at the following string:...Ch. 8 - Assume that d is a double variable. Write an if...Ch. 8 - Write code that displays the contents of the int...Ch. 8 - Prob. 11AWCh. 8 - Prob. 1SACh. 8 - Prob. 2SACh. 8 - Prob. 3SACh. 8 - Prob. 4SACh. 8 - Prob. 5SACh. 8 - Prob. 1PCCh. 8 - Prob. 2PCCh. 8 - Prob. 3PCCh. 8 - Prob. 4PCCh. 8 - Prob. 5PCCh. 8 - Prob. 6PCCh. 8 - Check Writer Write a program that displays a...Ch. 8 - Prob. 8PCCh. 8 - Prob. 9PCCh. 8 - Word Counter Write a program that asks the user...Ch. 8 - Sales Analysis If you have downloaded the books...Ch. 8 - Prob. 12PCCh. 8 - Alphabetic Telephone Number Translator Many...Ch. 8 - Word Separator Write a program that accepts as...Ch. 8 - Pig Latin Write a program that reads a sentence as...Ch. 8 - Prob. 16PCCh. 8 - Lottery Statistics To play the PowerBall lottery,...Ch. 8 - Gas Prices In the student sample program files for...
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
  • Text book image
    EBK JAVA PROGRAMMING
    Computer Science
    ISBN:9781337671385
    Author:FARRELL
    Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT