Can you please verify its correct when you finish because Iv

Can you please verify its correct when you finish because I\'ve posted this multiple times but I\'ve been getting wrong answers from other people who try it. (PLEASE USE C++ CODE) Thank You

In this assignment, you are going to write a program to decode messages using codes such as Morse code. This programs will use the class Code. The program will use the class to decode a message. The Morse code table is given below :

Our software will support codes that consist of symbols followed by a blank space. For example, in a message if an A appears, it will be replace by \".- \". The trailing space indicates the end of the codeword for that character. (NOTE: We will only be using the characters A-Z. Morse code words are separated by a space, so the message \"cat\" would be -.-. .- - x where x indicates the end of message. Note that spaces between words are denoted by 7 dots \".......\". You can assume that encoded messages end with a lowercase x (which means STOP). When converting a message from text to code, a period \".\" should be converted to an x.)

Requirements

Your program should include the following class :

class Code

{

public:

Code(); // Default constructor - loads and uses morse code

Code(vector codewords); // constructor loading customized code

string encode(vector message); // encodes a message consisting of A-Z

string decode(vector message); // decodes a message

private:

vector codewords; // this is a codeword vector parallel to A-Z

vector alpha; // this is the vector A-Z

vector alphacode(); // function builds the vector alpha - A B C etc.

vector morsecode(); // function the vector codewords containing morse code

string encode(char x); //returns the codeword for the character x

char decode(string c); //returns the character for the codeword c.

};

The decode will input a morse code string from a file and use the classto build the decoded string, and then output the string. You can download the functions morsecode and alphacode.

International Morse Code 1. A dash is equal to three dots 2. The space between parts of the same letter is equal to one dot. 3. The space between two letters is equal to three dots 4. The space between two words is equal to seven dots.

Solution

#include <iostream>
#include <string>


using namespace std;

string texttomorse (string textin)
{


string out = \" \";

for (int i=0; textin[i]; i++)
{
switch (toupper(textin[i]))
{
case \'A\': out += \"._\";
break;
case \'B\': out += \"-...\";
break;
case \'C\': out += \"-.-.\";
break;
case \'D\': out += \"-..\";
break;
case \'E\': out += \".\";
break;
case \'F\': out += \"..-.\";
break;
case \'G\': out += \"--.\";
break;
case \'H\': out += \"....\";
break;
case \'I\': out += \"..\";
break;
case \'J\': out += \".---\";
break;
case \'K\': out += \"-.-\";
break;
case \'L\': out += \".-..\";
break;
case \'M\': out += \"--\";
break;
case \'N\': out += \"-.\";
break;
case \'O\': out += \"---\";
break;
case \'P\': out += \".--.\";
break;
case \'Q\': out += \"--.-\";
break;
case \'R\': out += \".-.\";
break;
case \'S\': out += \"...\";
break;
case \'T\': out += \"-\";
break;
case \'U\': out += \"..-\";
break;
case \'V\': out += \"...-\";
break;
case \'W\': out += \".--\";
break;
case \'X\': out += \"-..-\";
break;
case \'Y\': out += \"-.--\";
break;
case \'Z\': out += \"--..\";
break;
case \'Å\': out += \".--.-\";
break;
case \'Ä\': out += \".-.-\";
break;
case \'Ö\': out += \"---.\";
break;
default: out;
}
out += \" \";
}
return out;
}

#include <iostream>
#include <string>
#include <iomanip>

using namespace std;

int main ()
{


string input, choice;

do
{

cout << setw(45) << \"****************************\ \";
cout << setw(45) << \"****Morse****\ \";
cout << setw(45) << \"****************************\ \";
cout << \"\ \ \ \";

cout << \"\\tA ._ K -.- U ..-\ \"
<< \"\\tB -... L .-.. V ...-\ \"
<< \"\\tC -.-. M -- W .--\ \"
<< \"\\tD -.. N -. X -..-\ \"
<< \"\\tE . O --- Y -.--\ \"
<< \"\\tF ..-. P .--. Z --..\ \"
<< \"\\tG --. Q --.- Å .--.-\ \"
<< \"\\tH .... R .-. Ä .-.-\ \"
<< \"\\tI .. S ... Ö ---.\ \"
<< \"\\tJ .--- T -\ \ \ \";

cout << \"Encoding morse code\ \"
<< \"---------------------\ \"
<< \"(0) Program.\ \"
<< \"(1) Morse code.\ \"
<< \"(2) Text.\ \";
cout << \"Val: \";
getline(cin, choice);

if (choice == \"1\")
{
cout << \"\ \ Type the text you want to translate: \";
getline(cin, input);
cout << \"\ \ \";
cout << \"Your text translate is: \" << texttomorse(input);
cout << \"\ \ \";
}
else if (choice == \"2\")
{
cout << \"\ Enter the code you want to translate :\";
getline(cin, input);
cout << texttomorse(input);
cout << \"\ \ \";
}
else if (choice == \"0\")
{
cout << \"The program ends, welcome back\ \ \";
}
else
cout << \"\ \\aincorrect input!!!!\ \ \";
}while (!(choice == \"0\"));
}


Output:

****************************
                               ****Morse****
                ****************************

   A ._ K -.- U ..-
   B -... L .-.. V ...-
   C -.-. M -- W .--
   D -.. N -. X -..-
   E . O --- Y -.--
   F ..-. P .--. Z --..
   G --. Q --.- Å .--.-
   H .... R .-. Ä .-.-
   I .. S ... Ö ---.
   J .--- T -


Encoding morse code
---------------------
(0) Program.
(1) Morse code.
(2) Text.
Val:
incorrect input!!!!

Can you please verify its correct when you finish because I\'ve posted this multiple times but I\'ve been getting wrong answers from other people who try it. (P
Can you please verify its correct when you finish because I\'ve posted this multiple times but I\'ve been getting wrong answers from other people who try it. (P
Can you please verify its correct when you finish because I\'ve posted this multiple times but I\'ve been getting wrong answers from other people who try it. (P
Can you please verify its correct when you finish because I\'ve posted this multiple times but I\'ve been getting wrong answers from other people who try it. (P

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site