Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Part A - Characters to Morse Code Format You are going to create a Morse Code translator in C/C++. You may use either C or
Part A - Characters to Morse Code Format You are going to create a Morse Code translator in C/C++. You may use either C or C++ for this assignment. This program will read an input file which will have a series of words using the English Alphabet characters a-z, A-Z. These words will be space delimited with no punctuation. Sentences will terminate with a newline. A file might look something like this: this is a test this too is a test SOS We will be using the International Standard of Morse Code: Remember, you should be handling both lowercase and uppercase letters the same. Characters 'a' and 'A' should translate to the same pattern ".-". The input file will consist of several lines of words with the maximum length of a line being 255 characters (including spaces). There can be any number of lines in a file.Read the file a line at a time as a C-Style String (character array that ends in \\0). Process through each character in the line to translate that character into the appropriate Morse Code pattern. Output that pattern to the output file. Each character should be separated by a | and an actual space should be outputted as a /. If you read in the line "the cat" the output would be: "the cat" > -| . ...1.1/1-.-. | . -I- This is a Row-by-row, character-by-character algorithm. DO NOT try to be clever here. DO NOT just read a single character at a time from the file. Part A Notes: . Remember you are outputting the Morse Code to an output file! o You may also output it to stdout as well if you choose . use some form of getline () to read an entire line from the file o C's getline() can take a file pointer as the source parameter o C++'s cin. getline can be used with your ifstream, if your ifstream is named infile you can do infile. getline() . fscanf("%s") won't be helpful here because scanf delimits on spaces and newlines after reading a whole line from the file, you can use strtok() with space as your delimeter to split up the line into words if you want o process each word a character at a time o You can also just process the whole line a character at a time without tokenizing. . The maximum line length will be 255 characters.Part B - Translate Morse Code back into English Alphabet In Part B, you're going to take a Morse Code file and translate it back into the English Alphabet. This is "easy" if you use strtok() properly and stromp() properly. Reach the Morse Code file a line at a time. The line will be a maximum of ~1785 characters. I think the worse the line can be is 255 characters that translate to a 4 pattern in morse code with a space between each character ie: ----1/| Output the English Character to the output file. Part B Notes: . Remember you're outputting to an output file o You may also output to stdout if you choose . You really only have one delimeter to worry about here | o / represents a space, so handle it accordingly . Look up stromp in #include trust me Requirements: Command line interface: This program will not have any menu interface. It will work entirely as a command line utility. Syntax:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started