Question: Morse Code Converter Design a program that asks the user to enter a string and then converts that string to Morse code. Morse code is

Morse Code Converter Design a program that asks the user to enter a string and then converts that string to Morse code. 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-7shows part of the code. Table 8-7 Morse code Character Code Character Code Character Code Character Code space space 6 -.... G --. Q --.- comma --..-- 7 --... H .... R .-. period .-.-.- 8 ---.. I .. S ? ..--.. 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 --..

Programming language- C# Visual Basic

Here is my code:

private void convertButton_Click(object sender, EventArgs e) { { Dictionary morseCode = new Dictionary() {

{'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' , "--.."},

{'0' , "-----"},{'1' , ".----"},{'2' , "..----"},{'3' , "...--"}, {'4' , "....-"},{'5' , "....."},{'6' , "-...."},{'7' , "--..."}, {'8' , "---.."},{'9' , "----."},{'?' , "..--.."},{'.' , ".-.-.-"}, {' ' , " " }, {',' , "--..--"}

}; string wordOrPhrase = convertInputTextBox.Text; wordOrPhrase = convertInputTextBox.ToString(); //string codeConvert = string.Empty; char Letter_number; foreach (char ch in wordOrPhrase) { // char.ToUpper(ch); //Letter_number = char.ToUpper(ch); if (wordOrPhrase.ContainsKey(morseCode)) { morseCodeOutputLabel.Text += morseCode[Letter_number];

} } } }

My issue: Everything seems correct with the dictionary and the input, but I can't seem to get the logic down. I am trying to have the user input a phrase or word then have the label output the morse code as a phrase or a word.

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!