Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can someone help me check this code? The output didnot show the morse code. And I need the flowchart. Thank you so much! import java.io.*;

Can someone help me check this code? The output didnot show the morse code. And I need the flowchart. Thank you so much!

image text in transcribed

import java.io.*; import java.util.*; public class Morse { public static int NUM_CHARS = 40; private String original; private String mcode; private char[] regular; private char[] morse;

Morse(String m) { original = m; }

public String toMorse(char ch) { char[] regular = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l','m', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0',',', '.', '?',' ' };

String[] morse ={ ".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..", ".---", "-.-", ".-..", "--", "-.", "---", ".---.", "--.-", ".-.","...", "-", "..-", "...-", ".--", "-..-", "-.--", "--..", ".----","..---", "...--", "....-", ".....", "-....", "--...", "---..", "----.","-----", "--..--", ".-.-.-", "..--.."," " }; return " "; }

public String getMorseCode() {

for(int i = 0; i

for (short j = 0; j

if (original.charAt(i) == regular[j]) {

mcode += morse[j];

mcode += " "; } } } return mcode; } public String getOriginal() { return original; } }

import java.util.*;

public class Main { public static void main(String[] args) { System.out.print("Enter the string (To a maximum of 40 characters): "); Scanner sc = new Scanner(System.in); String original = sc.nextLine(); Morse message = new Morse(original); System.out.println("The morse code equivalent of: "+message.getOriginal()+" is: "+message.getMorseCode()); } }

Morse + NUM CHARS int -40 original : String mcode : String regular : char[] morse : char[ ] + Morse(input: String) + toMorse(ch : char): String + getMorseCode0) : String + getOriginal): String

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Seven Databases In Seven Weeks A Guide To Modern Databases And The NoSQL Movement

Authors: Luc Perkins, Eric Redmond, Jim Wilson

2nd Edition

1680502530, 978-1680502534

More Books

Students also viewed these Databases questions

Question

=+How should it be delivered?

Answered: 1 week ago