Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

******I ONLY NEED ENCODE NOT DECODE*********** In this homework assignment, you are golng to write 2 programs to encode and decode messages using codes such

image text in transcribedimage text in transcribedimage text in transcribed

******I ONLY NEED ENCODE NOT DECODE***********

In this homework assignment, you are golng to write 2 programs to encode and decode messages using codes such as Morse code. NOT You will he writing two programs. Both programs will use the class Code. One program will use the class to encode a messaqe. The second wll use the code to decode the message. The Morse code table 1s glven below: International Morse Code A dashis equalto thzee dots 2 The space between parts of the same letter is equal to one dot. 3 The space between two letters is equal te three dots 4 "paca b ween two weeds isojualto seven does Our software wtll 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 tratling space indtcates 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 prugram should include the lowing class: public Code Detault constructor laads and uses merse code Code vectorint codewords) constructor loading custonizcd code string encodelvectorcchars nessage encodes anessage consisting of A-z tring decodelvectorsstringa nessag: decodes a nessage private: vector morsecode () // This function returns a vector containing the morse code vector temp (28); temp [0] =" temp [1] "- . . . "; temp [2] ="-...". temp [3] -"-.."; temp [4] ="." temp[5]-". .-." temp [6] ="--.". temp [7] =" "; temp [8] -" ."; temp [9] =" ". temp[10] temp[11] -".-..'" temp [ 12 ] ="--" temp [ 13 ] ="-.... temp [ 14 ] =" " temp[15] -". -- . temp [16] -"-- . -." temp [17] =" temp [ 18 ] .. temp [ 19 ] ="-" : temp [20] -".. - "; temp[21] ". temp [22] ". -- "; temp [23] -"- . . - "; temp [24] -"- . --"; temp [25] "-- . ."; temp [27] ="x". return temp; ALPHACODE vector alphacode() // This returns a vector containing the alphabet a-z and"" vector temp; temp.push_back (c) temp.push_back(' ); temp, pushback('') ; return temp; - In this homework assignment, you are golng to write 2 programs to encode and decode messages using codes such as Morse code. NOT You will he writing two programs. Both programs will use the class Code. One program will use the class to encode a messaqe. The second wll use the code to decode the message. The Morse code table 1s glven below: International Morse Code A dashis equalto thzee dots 2 The space between parts of the same letter is equal to one dot. 3 The space between two letters is equal te three dots 4 "paca b ween two weeds isojualto seven does Our software wtll 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 tratling space indtcates 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 prugram should include the lowing class: public Code Detault constructor laads and uses merse code Code vectorint codewords) constructor loading custonizcd code string encodelvectorcchars nessage encodes anessage consisting of A-z tring decodelvectorsstringa nessag: decodes a nessage private: vector morsecode () // This function returns a vector containing the morse code vector temp (28); temp [0] =" temp [1] "- . . . "; temp [2] ="-...". temp [3] -"-.."; temp [4] ="." temp[5]-". .-." temp [6] ="--.". temp [7] =" "; temp [8] -" ."; temp [9] =" ". temp[10] temp[11] -".-..'" temp [ 12 ] ="--" temp [ 13 ] ="-.... temp [ 14 ] =" " temp[15] -". -- . temp [16] -"-- . -." temp [17] =" temp [ 18 ] .. temp [ 19 ] ="-" : temp [20] -".. - "; temp[21] ". temp [22] ". -- "; temp [23] -"- . . - "; temp [24] -"- . --"; temp [25] "-- . ."; temp [27] ="x". return temp; ALPHACODE vector alphacode() // This returns a vector containing the alphabet a-z and"" vector temp; temp.push_back (c) temp.push_back(' ); temp, pushback('') ; return temp

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

PC Magazine Guide To Client Server Databases

Authors: Joe Salemi

1st Edition

156276070X, 978-1562760700

More Books

Students also viewed these Databases questions