Starting Out with Java: From Control Structures through Objects (6th Edition)
6th Edition
ISBN: 9780133957051
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 9, 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.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
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.
1.
This program reads one number, as a string, and assign it to String getData
Increment and display getData as integer and double
Only strings are to be read
2.
This program reads strings only
Read ten digits, such as 2345678923
store them in getData, which is a string
Display each value and it position in the string
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 9 Solutions
Starting Out with Java: From Control Structures through Objects (6th Edition)
Ch. 9.2 - Prob. 9.1CPCh. 9.2 - Write an if statement that displays the word digit...Ch. 9.2 - Prob. 9.3CPCh. 9.2 - Write a loop that asks the user, Do you want to...Ch. 9.2 - Prob. 9.5CPCh. 9.2 - Write a loop that counts the number of uppercase...Ch. 9.3 - Prob. 9.7CPCh. 9.3 - Modify the method you wrote for Checkpoint 9.7 so...Ch. 9.3 - Look at the following declaration: String cafeName...Ch. 9.3 - Prob. 9.10CP
Ch. 9.3 - Prob. 9.11CPCh. 9.3 - Prob. 9.12CPCh. 9.3 - Prob. 9.13CPCh. 9.3 - Look at the following code: String str1 = To be,...Ch. 9.3 - Prob. 9.15CPCh. 9.3 - Assume that a program has the following...Ch. 9.4 - Prob. 9.17CPCh. 9.4 - Prob. 9.18CPCh. 9.4 - Prob. 9.19CPCh. 9.4 - Prob. 9.20CPCh. 9.4 - Prob. 9.21CPCh. 9.4 - Prob. 9.22CPCh. 9.4 - Prob. 9.23CPCh. 9.4 - Prob. 9.24CPCh. 9.5 - Prob. 9.25CPCh. 9.5 - Prob. 9.26CPCh. 9.5 - Look at the following string:...Ch. 9.5 - Prob. 9.28CPCh. 9.6 - Write a statement that converts the following...Ch. 9.6 - Prob. 9.30CPCh. 9.6 - Prob. 9.31CPCh. 9 - The isDigit, isLetter, and isLetterOrDigit methods...Ch. 9 - Prob. 2MCCh. 9 - The startsWith, endsWith, and regionMatches...Ch. 9 - The indexOf and lastIndexOf methods are members of...Ch. 9 - Prob. 5MCCh. 9 - Prob. 6MCCh. 9 - Prob. 7MCCh. 9 - Prob. 8MCCh. 9 - Prob. 9MCCh. 9 - Prob. 10MCCh. 9 - To delete a specific character in a StringBuilder...Ch. 9 - Prob. 12MCCh. 9 - This String method breaks a string into tokens. a....Ch. 9 - These static final variables are members of the...Ch. 9 - Prob. 15TFCh. 9 - Prob. 16TFCh. 9 - True or False: If toLowerCase methods argument is...Ch. 9 - True or False: The startsWith and endsWith methods...Ch. 9 - True or False: There are two versions of the...Ch. 9 - Prob. 20TFCh. 9 - Prob. 21TFCh. 9 - Prob. 22TFCh. 9 - Prob. 23TFCh. 9 - int number = 99; String str; // Convert number to...Ch. 9 - Prob. 2FTECh. 9 - Prob. 3FTECh. 9 - Prob. 4FTECh. 9 - The following if statement determines whether...Ch. 9 - Write a loop that counts the number of space...Ch. 9 - Prob. 3AWCh. 9 - Prob. 4AWCh. 9 - Prob. 5AWCh. 9 - Modify the method you wrote for Algorithm...Ch. 9 - Prob. 7AWCh. 9 - Look at the following string:...Ch. 9 - Assume that d is a double variable. Write an if...Ch. 9 - Write code that displays the contents of the int...Ch. 9 - Prob. 1SACh. 9 - Prob. 2SACh. 9 - Prob. 3SACh. 9 - How can you determine the minimum and maximum...Ch. 9 - Prob. 1PCCh. 9 - Prob. 2PCCh. 9 - Prob. 3PCCh. 9 - Prob. 4PCCh. 9 - Prob. 5PCCh. 9 - Prob. 6PCCh. 9 - Check Writer Write a program that displays a...Ch. 9 - Prob. 8PCCh. 9 - Prob. 9PCCh. 9 - Word Counter Write a program that asks the user...Ch. 9 - Sales Analysis The file SalesData.txt, in this...Ch. 9 - Prob. 12PCCh. 9 - Alphabetic Telephone Number Translator Many...Ch. 9 - Word Separator Write a program that accepts as...Ch. 9 - Pig Latin Write a program that reads a sentence as...Ch. 9 - Prob. 16PC
Knowledge Booster
Similar questions
- C# language MORSE CODE CONVERTERDesign a program that asks the user to enter a string and thenconverts that string to Morse code. Morse code is a code whereeach letter of the English alphabet, each digit, and variouspunctuation characters are represented by a series of dots anddashes. Table 8-9 shows part of the code. Needs to be two labels, two text boxes and click button for conversionarrow_forwardQ: People often forget closing parentheses when entering formulas. Write a program that asks the user to enter a formula and prints out whether the formula has the same number of opening and closing parentheses. Q: Write a program that asks the user to enter a word and prints out whether that word contains any vowels. Q: Write a program that asks the user to enter a string. The program should create a new string called new_string from the user’s string such that the second character is changed to an asterisk and three exclamation points are attached to the end of the string. Finally, print new_string. Typical output is shown below: Enter your string: Qbert Q*ert!!! Q: Write a program that asks the user to enter a string s and then converts s to lowercase, removes all the periods and commas from s, and prints the resulting string. Q: Write a program that asks the user to enter a word and determines whether the word is a palindrome or not. A palindrome is a word that reads the same…arrow_forwardUsing an instance of a string, you may determine the location of the substring.arrow_forward
- One of the string objects may be used to determine where the substring is.arrow_forwardFrench Articles: French country names are feminine when they end with the letter e, masculine otherwise, except for the following which are masculine even though they end with e: le Belize le Cambodge le Mexique le Mozambique le Zaïre le Zimbabwe Write a program that reads the French name of a country and adds the article: le for masculine or la for feminine, such as le Canada or la Belgique. However, if the country name starts with a vowel, use l’; for example, l’Afghanistan. For the following plural country names, use les: les Etats-Unis les Pays-Basarrow_forwardA string is a term that refers to a group of objects that are connected byarrow_forward
- 7bact1 Please help me answer this in python programming.arrow_forwardJava please Line is a String object that holds an unknown number of int values separated by spaces. Write a segment of code that computes and displays the sum of the values in line.arrow_forwardA string object's functions may be used to find out the location of a substring when it is a substring of another string object.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT