Question: Your program Assignment Morse code is a code where each letter of the English alphabet, each digit, and various punctuation characters are represented by a

Your program Assignment 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. There is a table in the book that shows part of the code. Below is some C++ code that puts the code and alphabet into parallel arrays. static int MORSESIZE = 40; // size of morse code table // LETTERMATCH is a parallel array with MORSECODE for matching purposes static char LETTERMATCH[40] = {' ',',','.','?','0','1','2','3','4','5','6','7','8','9','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'}; // [SP] , . ? 0 1 2 3 4 5 static string MORSECODE[40] = { " ","--..--",".-.-.-","..--..","----- ",".----","..---","...--","....-",".....", // 6 7 8 9 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 "--.-",".-.","...","-","..- ","...-",".--","-..-","-.--","--.."}; You could copy this and drop it into your code if you choose. 1. Write a program that asks the user to enter a string, and then converts that string to Morse code. 2. Arrange the output where you show the words entered and next to it the morse code for the word. (see Example). 3. Use a looping structure to allow user to enter strings multiple times without exiting the program

This is what I have so far

#include using namespace std;

int main() { char again = 'y';

char morse[37][6] = { ".-","-...","-.-.","-..",".","..-.","--.","....","..",".---", "-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-", "..-","...-",".--","-..-","-.--","--..",".----","..---","...--", "....-",".....","-....","--...","---..","----.","-----"," " }; char input[50]; char letnum[37] = { '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',' ' }; int i = 0, j, k; while (again == 'y') //loop the program to ask the user if they would like to run it again { cout << " " "input a string: "; cin.getline(input, 37); while (input[i] != '.') { for (j = 0; j < 37; j++) { if (toupper(input[i]) == letnum[j]) { for (k = 0; k < strlen(morse[j]); k++) cout << morse[j][k]; cout << " "; } } i++; } The problem I'm having is that when the loop executes it wont let me re-input the values for the morse code it only re asks the question to re run the program.

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!