Lab 6
Lab 6
by telegraph
from Washington to Baltimore, heralding the beginning of the age of electronic communication.
To make it possible to communicate information using only the presence or absence of a single
tone, Morse designed a coding system in which letters and other symbols are represented as coded
sequences of short and long tones, traditionally called dots and dashes.
In Morse code, the 26 letters of the alphabet are represented by the codes shown in Figure below.
Write a program that reads in lines from the user and translates each line either to or from Morse
code depending on the first character of the line:
If the line starts with a letter, you want to translate it to Morse code.
Any characters other than the 26 letters should simply be ignored. (you can code your
program to handle the numbers 0 to 9 if you wish)
If the line starts with a period (dot) or a hyphen (dash), it should be read as a series of Morse
code characters that you need to translate back to letters.
Each sequence of dots and dashes is separated by spaces, but any other characters should
be ignored.
Because there is no encoding for the space between words, the characters of the
translated message will be run together when your program translates in this direction.
The program should end when the user enters a blank line.