Question

Morse code is a code where each letter of the English alphabet, cach digit, and various punctuation characters are represente
Please make sure all requirements are met and as well have comments to explain the program throughout.
C++ Programming
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code -


#include <iostream>
using namespace std;
//FUNCTION morseEncode which take char as arguement
//and convert that character to string ecoded form
string morseEncode(char x) {

switch (x) {
case ' ':
   return "space";
case ',':
   return "--..--";
case '>':
   return ".-.-.-";
case '?':
   return "..--..";
case '0':
   return "-----";
case '1':
   return ".----";
case '2':
   return "..---";
case '3':
   return "...--";
case '4':
   return "....-";
case '5':
   return ".....";
case '6':
   return "-....";
case '7':
   return "--...";
case '8':
   return "---..";
case '9':
   return "----.";
case 'A':
   return ".-";
case 'B':
   return "-...";
case 'C':
   return "-.-.";
case 'D':
   return "-..";
case 'E':
   return ".";
case 'F':
   return "..-.";
case 'G':
   return "--.";
case 'H':
   return "....";
case 'I':
   return "..";
case 'J':
   return ".---";
case 'K':
   return "-.-";
case 'L':
   return ".-..";
case 'M':
   return "--";
case 'N':
   return "-.";
case 'O':
   return "---";
case 'P':
   return ".--.";
case 'Q':
   return "--.-";
case 'R':
   return ".-.";
case 'S':
   return "...";
case 'T':
   return "-";
case 'U':
   return "..-";
case 'V':
   return "...-";
case 'W':
   return ".--";
case 'X':
   return "-..-";
case 'Y':
   return "-.--";
case 'Z':
   return "--..";
}
}
//FUNCTION printMorseCode
void printMorseCode(string s) {
//iterate over the string and call function morseEncode and
//pass each char from string to this function
for (int i = 0; s[i]; i++)
//print encoded output
   cout << morseEncode(s[i])<<" ";
cout << endl;
}

// Driver's code
int main() {
string s;
//ASK USER TO ENTER A STRING
cout<<"Enter a string "<<endl;
//STORE IN S
cin>>s;
//CALL FUNCTION printMorseCode and pass string in it
printMorseCode(s);
return 0;
}

Screenshots - When giving string as input, pls give all alphabets in capital letters. if you give in small letter it will give error

Enter a string ABCDEFG123456 ?>, -- -... -.-. -.. . ..-. --. .---- ..--- ...-- ....- ..... .... ... Program finished with exi

pls do give a like , thank you

Add a comment
Know the answer?
Add Answer to:
Please make sure all requirements are met and as well have comments to explain the program...
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...

  • 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...

  • 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...

  • 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...

  • 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...

  • My C++ program is not compiling. Please explain how you fixed with detailed inline comments. I am using Visual Studio 2017. It's a character count program that keeps and displays a count of all th...

    My C++ program is not compiling. Please explain how you fixed with detailed inline comments. I am using Visual Studio 2017. It's a character count program that keeps and displays a count of all the upper, lower case and digits in a .txt file. The requirement is to use classes to implement it. -----------------------------------------------------------------HEADER FILE - Text.h--------------------------------------------------------------------------------------------- /* Header file contains only the class declarations and method prototypes. Comple class definitions will be in the class file.*/ #ifndef TEXT_H #define...

  • 1) Echo the input: First, you should make sure you can write a program and have...

    1) Echo the input: First, you should make sure you can write a program and have it compile and run, take input and give output. So to start you should just echo the input. This means you should prompt the user for the plaintext, read it in and then print it back out, with a message such as "this is the plaintext you entered:". [4 points, for writing a working program, echoing the input and submitting the program on the...

  • A CERTAIN program to user's password containing rules such as least n length, one uppercase, lowercase,...

    A CERTAIN program to user's password containing rules such as least n length, one uppercase, lowercase, one digit and white space is given as the code down below. So, simiiar to those rules, I need the code for the following questions post in pictures such as no more three consecutive letters of English alphabets, password should not contain User name and so on. //GOAL: To learn how to create that make strong passwords //Purpose: 1)To learn some rules that makes...

  • Write a c++ program in that file to perform a “Search and Replace All” operation. This...

    Write a c++ program in that file to perform a “Search and Replace All” operation. This operation consists of performing a case-sensitive search for all occurrences of an arbitrary sequence of characters within a file and substituting another arbitrary sequence in place of them. Please note: One of the biggest problems some students have with this exercise occurs simply because they don’t read the command line information in the course document titled “Using the Compiler’s IDE”. Your program: 1. must...

  • In C++ Having heard you have gotten really good at programming, your friend has come to...

    In C++ Having heard you have gotten really good at programming, your friend has come to ask for your help with a simple task. She would like you to implement a program to encrypt the messages she exchanges with her friends. The idea is very simple. Every letter of the alphabet will be substituted with some other letter according to a given key pattern like the one below. "abcdefghijklmnopqrstuvwxyz" "doxrhvauspntbcmqlfgwijezky" // key pattern For example, every 'a' will become a...

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