Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2019 Wurzburg Germany September 16 20 2019 Proceedings Part 2 Lnai 11907

Authors: Ulf Brefeld ,Elisa Fromont ,Andreas Hotho ,Arno Knobbe ,Marloes Maathuis ,Celine Robardet

1st Edition

3030461467, 978-3030461461

More Books

Students also viewed these Databases questions