Question: 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!

Can someone help me check this code? The output didnot show the

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!