0% found this document useful (0 votes)
157 views

Lab 6

Samuel Morse developed Morse code in 1844 to allow electronic communication through telegraphs. Morse code represents letters and symbols through combinations of short and long tones called dots and dashes. Morse's code assigned each of the 26 letters of the alphabet a unique sequence of dots and dashes as shown in the figure provided. The document then provides instructions for a program to translate text to and from Morse code based on whether the input line starts with a letter or dot/dash.

Uploaded by

zabith
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
157 views

Lab 6

Samuel Morse developed Morse code in 1844 to allow electronic communication through telegraphs. Morse code represents letters and symbols through combinations of short and long tones called dots and dashes. Morse's code assigned each of the 26 letters of the alphabet a unique sequence of dots and dashes as shown in the figure provided. The document then provides instructions for a program to translate text to and from Morse code based on whether the input line starts with a letter or dot/dash.

Uploaded by

zabith
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

In May of 1844, Samuel F. B. Morse sent the message What hath God wrought!

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.

You might also like