Repository with assignments using the Test Informed Learning with Examples (TILE) method to integrate testing into existing programming courses for free.
Join our LinkedIN Community.
Morse code is a coding scheme that uses hyphens and dots to represent digits and letters. In this exercise, we are going to write a program that uses a dictionary to store the mapping between these symbols and Morse code. Use a dot to represent a Morse dot, and a hyphens to represent a Morse hyphens. The mapping of characters to hyphens and dots is shown in the table below:
First, you have to write a function that translates words written in capitalized English into Morse code. The function must ignore any characters in the word that are not listed in the table above.
After testing the function well, you have to write a program called
main
that calls this function to translate a message that asks the
user. The user’s message can consist of more than one word separated
by a space.
For example, if you are a user, type the message Hello, World
! and
your program must return the following Morse code:
.... . .-.. .-.. --- .-- --- .-. .-.. -..