Translating dots and dashes.
Morse code is a method used in telecommunication to encode text characters as sequences of two different signal durations, called dots and dashes, or dits and dahs. In the 1890s, Morse code began to be used extensively for early radio communication before it was possible to transmit voice. In the late 19th and early 20th centuries, most high-speed international communication used Morse code on telegraph lines, undersea cables, and radio circuits. Today, Morse code has been replaced by the Global Maritime Distress and Safety System (GMDSS). This program translates Morse code in a file into plain text.
Write a program that reads a file containing Morse code with dots represented with a full stop: ".", dashes represented with hyphens: "-" and words separated with a space and forward slash: " / ". The program should output the contents of the file in English.
Use this boilerplate code as a starting point:
Remember to add a comment before a subprogram, selection or iteration statement to explain its purpose.
For a file containing:
••• •- — ••- • •-•• / — — •-• ••• • / •– •- ••• / •- -• / •- — • •-• •• -•-• •- -• / •–• •- •• -• – • •-• / •- -• -•• / •• -• •••- • -• – — •-• / •– •••• — / •• ••• / -••• • ••• – / •-• • — • — -••• • •-• • -•• / – — -•• •- -•– / ••-• — •-• / •••• •• ••• / •• -• •••- • -• – •• — -• / — ••-• / – •••• • / ••• •• -• –• •-•• • / •– •• •-• • / – • •-•• • –• •-• •- •–• •••• / ••• -•– ••• – • — / •- -• -•• / — — •-• ••• • / -•-• — -•• •
The output would be:
SAMUEL MORSE WAS AN AMERICAN PAINTER AND INVENTOR WHO IS BEST REMEMBERED TODAY FOR HIS INVENTION OF THE SINGLE WIRE TELEGRAPH SYSTEM AND MORSE CODE
Note: use the files: message1.txt and message2.txt in the Trinket, do not copy the morse code above into your program.
Use these resources as a reference to help you meet the success criteria.
Run the unit tests below to check that your program has met the success criteria.
Enter the filename: message1.txt
THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG
Enter the filename: message2.txt
SAMUEL MORSE WAS AN AMERICAN PAINTER AND INVENTOR WHO IS BEST REMEMBERED TODAY FOR HIS INVENTION OF THE SINGLE WIRE TELEGRAPH SYSTEM AND MORSE CODE
Check that you have: