Question

The Morese code was developed by Alfred Vail while he is working in 1830 with Samuel...

The Morese code was developed by Alfred Vail while he is working in 1830 with Samuel Morse in the invention of electric

telegraph . Vail created a method by which each letter or number was transmitted individually with a consistent code stripes

Y points , Ie telegraphic signals that differ in the duration of the active signal. Morse recognized the suitability of this

system and he patented together with the electric telegraph. It was known as American Morse Code and was used in the

first transmission by telegraph.

You will write a program that reads a message and should be stored in an array of strings, the strings representing each of

the characters of the message:

Example:

If the message is "Hello World", you should analyze character by character to arm the individual chains:

H - "· ·," O = "- - -" L = "· - ·" A = "· -" etc etc ...

- - - - \ 0
. . . . \ 0
- . - - \ 0
- .   \ 0

The program should read a string, you must determine the sequence of dots and dashes of each character and save in the array of strings.

Now, lets encrypt the message. In a copy of the settlement, you must place the strings, just that the dots will be dashes and dashes will be points

- - - - \ 0
. . . . \ 0
- . - - \ 0
- . \ 0

Finally you must interpret the new codes:

"- - - -" = O

". . . . "= H

"-. -. "= C

"-. "= N

The individual characters are going to put together a string.

You must write a program that has two options:

a) can read a character string ( only alphanumeric and spaces) and

encoding according to the above rules.

b) You can read an encoded according to the above rule and restore the original text message.

The program must be on code C

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include<stdio.h>

#include<string.h>

#define SIZE 100

void encode(const char *enmorse[], const char *enAph[], const char *enaph[]);

void decode(const char *enmorse[], const char *enAph[], const char *enaph[]);

int main()

{

const char *morse[27]={"._","_...","___.","_..",".",".._.","__.","....","..",".___","_._","._..","____","_.","___",".__.","__._","._.","...","_",".._","..._",".__","_.._","_.__","__..","..__"};

const char *Aph[27]={"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," "};

const char *aph[27]={"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"," "};

char string[SIZE];

int s;

printf("1. Morse Code Encoding\n2. Morse Code Decoding\nSelect 1 or 2:");

scanf("%d", &s);

fgets(string, SIZE, stdin);

if(s==1)

encode(morse, Aph, aph);

else if(s==2)

decode(morse, Aph, aph);

else

printf("please key in 1 or 2 , try it again\n");

printf("\n");

return 0;

}

void encode(const char *enmorse[], const char *enAph[], const char *enaph[])

{

char string[SIZE];

char c;

int i;

int j;

int s=0;

printf("Enter the messages then convert to the Morse codes\n");

fgets(string, SIZE, stdin);

for(i=0; i<SIZE; i++) {

for(j=0; j<27; j++) {

if((string[i]==*enAph[j])||(string[i]==*enaph[j]))

printf("%s ",enmorse[j]);

}

}

}

void decode(const char *enmorse[],const char *enAph[],const char *enaph[] )

{

char string[SIZE];

char *tokenPtr;

char s[SIZE];

int i;

printf("Enter the Morse codes then convert to the messages\n");

  

fgets(string, SIZE, stdin);

tokenPtr=strtok(string," ");

while (tokenPtr!= NULL) {

for(i=0;i<27;i++) {

strcmp(tokenPtr,enmorse[i]);

if(strcmp(tokenPtr,enmorse[i])==0)

printf("%s",enaph[i]);

}

tokenPtr=strtok(NULL," ");

}

}

Add a comment
Know the answer?
Add Answer to:
The Morese code was developed by Alfred Vail while he is working in 1830 with Samuel...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please write code using Python. Rubric Assignment Solution Total: 100 pts Program successfully retrieves and validates...

    Please write code using Python. Rubric Assignment Solution Total: 100 pts Program successfully retrieves and validates user input 15 pts Morse Code Function Created 10 pts Function Uses Parameters to get input message 15 pts Function successfully converts passed message to Morse Code and returns the Morse Code equivalent of message 45 pts Program calls Morse Code function and outputs the result of the function (i.e. the actual Morse Code) 15 pts Main Function Requirement Part 2 MUST have a...

  • msp430 launchpad 2553 C programming Write a program for the microcontroller that flashes the Morse code pattern of a string. The Morse code is a system used to transmit characters and numbers through...

    msp430 launchpad 2553 C programming Write a program for the microcontroller that flashes the Morse code pattern of a string. The Morse code is a system used to transmit characters and numbers through light or sound signals. Each character is mapped to a series of ‘dots’ and ‘dashes’ as shown below. For example, the letter A is (dot-dash), the letter B is (dash-dot-dot-dot) etc. To show a Morse letter on the microcontroller, the LED blinks for a short duration to...

  • Program Description: A Java program is to be created to produce Morse code. The Morse code...

    Program Description: A Java program is to be created to produce Morse code. The Morse code assigns a series of dots and dashes to each letter of the alphabet, each digit, and a few special characters (such as period, comma, colon, and semicolon). In sound-oriented systems, the dot represents a short sound and the dash represents a long sound. Separation between words is indicated by a space, or, quite simply, the absence of a dot or dash. In a sound-oriented...

  • Program Description: A C# app is to be created to produce Morse code. The Morse code...

    Program Description: A C# app is to be created to produce Morse code. The Morse code assigns a series of dots and dashes to each letter of the alphabet, each digit, and a few special characters (such as period, comma, colon, and semicolon). In sound-oriented systems, the dot represents a short sound and the dash represents a long sound. Separation between words is indicated by a space, or, quite simply, the absence of a dot or dash. In a sound-oriented...

  • c programming

    Write a c program that reads a string with a maximum length of 30 from the keyboard[1]. The program should then copy the characters from that input string into a second character array (in order of input). However, only if a character is a vowel (a, e, i, o, u) should it be copied into the second array. Once copied, the program should output the values stored in the second array (in order of input). The program should then count...

  • I need eclipse code for : Write a program that analyzes text written in the console...

    I need eclipse code for : Write a program that analyzes text written in the console by counting the number of times each of the 26 letters in the alphabet occurs. Uppercase and lowercase letters should be counted together (for example, both ‘A’ and ‘a’ should count as an A). Any characters that are not letters should be ignored. You must prompt the user to enter the text to be analyzed. Then, for any letter that appeared at least once...

  • Objectives: Use strings and string library functions. Write a program that asks the user to enter...

    Objectives: Use strings and string library functions. Write a program that asks the user to enter a string and output the string in all uppercase letters. The program should then display the number of white space characters in the string. You program should run continuously until the user enters an empty string. The program must use the following two functions: A function called count_spaces that counts the number of white spaces inside a string. int count_space(char str[]); which tell you...

  • so i have my c++ code and ive been working on this for hours but i...

    so i have my c++ code and ive been working on this for hours but i cant get it to run im not allowed to use arrays. im not sure how to fix it thank you for the help our job is to write a menu driven program that can convert to display Morse Code ere is the menu the program should display Menu Alphabet Initials N-Numbers - Punctuations S = User Sentence Q- Quit Enter command the user chooses...

  • Please use Visual Studio! Let me know if you need anything else <3 #include <stdio.h> #include...

    Please use Visual Studio! Let me know if you need anything else <3 #include <stdio.h> #include <string.h> #pragma warning(disable : 4996) // compiler directive for Visual Studio only // Read before you start: // You are given a partially complete program. Complete the functions in order for this program to work successfully. // All instructions are given above the required functions, please read them and follow them carefully. // You shoud not modify the function return types or parameters. //...

  • NOTE: Write the Program in python as mentioned below and use while loop and flags as...

    NOTE: Write the Program in python as mentioned below and use while loop and flags as necessary. And please write the code following the program description given below. Directions: Read the program description below carefully. All requirements must be met by your program to receive full credit. Thus, pay particular attention to input and output requirements, structural requirements, and so on. Furthermore, code that contains syntax errors will not receive any credit, so be sure that your code interprets correctly...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT