Question

In this laboratory we are going to do part of the Homework 2 assignment. We will...

In this laboratory we are going to do part of the Homework 2 assignment. We will be creating the program which takes a file containing the message in morse code and converts it to the alphabetic message.

Your program should include the following functions :

class Code
{
public:
  
  Code();  // Default constructor - loads and uses morse code

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

private:

  vector<string> codewords; // this is a codeword vector parallel to A-Z
  vector<char> alpha; // this is the vector for A-Z

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

  vector<string>  morsecode(); // function builds the vector codewords containing morse code

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

};


Your main program will use the above class to input a morse code message from a file. Since every codeword is separated by a space, you can input the message using cin, and store each codeword as a separate string in a vector. Then submit the vector to the class function decode, and it will return the decoded message. When finished, output the string. You can download the functions morsecode and alphacode. Use your program to decode the messages message 1 and message 2.

Message 1:

-.. --- -. - ....... ..-. --- .-. --. . - ....... - --- ....... -.. .-. .. -. -.- ....... -.-- --- ..- .-. ....... --- ...- .- .-.. - .. -. . x

Message 2:

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

Solution(s):

Add a comment
Know the answer?
Add Answer to:
In this laboratory we are going to do part of the Homework 2 assignment. We will...
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
  • MUST WRITE IN C++ Objective: Learn how to design classes using abstract classes and inheritance Assignment:...

    MUST WRITE IN C++ Objective: Learn how to design classes using abstract classes and inheritance Assignment: In cryptography, encryption is the process of encoding a message or information in such a way that only authorized parties can access it. In this lab you will write a program to decode a message that has been encrypted using two different encryption algorithms. Detailed specifications: Define an abstract class that will be the base class for other two classes. It should have: A...

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

  • WE ARE USING PYTHON TO COMPLETE THIS ASSIGNMENT :) THANK YOU! In this programming assignment, you...

    WE ARE USING PYTHON TO COMPLETE THIS ASSIGNMENT :) THANK YOU! In this programming assignment, you will write functions to encrypt and decrypt messages using simple substitution ciphers. Your solution MUST include: a function called encode that takes two parameters: key, a 26-character long string that identifies the ciphertext mapping for each letter of the alphabet, in order; plaintext, a string of unspecified length that represents the message to be encoded. encode will return a string representing the ciphertext. a...

  • I'm also having trouble on dividing the code into methods. This is my work done so...

    I'm also having trouble on dividing the code into methods. This is my work done so far and net beans give me a lot of errors. Help! package caesarcipher; import textio.TextIO; /** * * @author */ public class CaesarCipher { enum code {encodeText, decodeText }; /** * @param args the command line arguments */ public static void main(String[] args) {    String code; char x;    int totalcount = 0;    while(true){ TextIO.put("Type in an E to encode a message...

  • cs55(java) please Part 1: You are a programming intern at the student transfer counselor's office. Having...

    cs55(java) please Part 1: You are a programming intern at the student transfer counselor's office. Having heard you are taking CS 55, your boss has come to ask for your help with a task. Students often come to ask her whether their GPA is good enough to transfer to some college to study some major and she has to look up the GPA requirements for a school and its majors in a spreadsheet to answer their question. She would like...

  • Can someone please help me for this assignment? Cryptography — the science of secret writing —...

    Can someone please help me for this assignment? Cryptography — the science of secret writing — is an old science; the first recorded use was well before 1900 B.C. An Egyptian writer used previously unknown hieroglyphs in an inscription. We will use a simple substitution cypher called rot13 to encode and decode our secret messages. ROT13 ("rotate by 13 places", sometimes hyphenated ROT-13) is a simple letter substitution cipher that replaces a letter with the 13th letter after it, in...

  • I uploaded this question twice already and no one had the expertise to answer the question correc...

    I uploaded this question twice already and no one had the expertise to answer the question correctly. Please assign an Analysis of Algorithms Expert. You're allowed to use any language (state it) providing the solution pass all test cases (they are anonymous). Unique Codewords HackerRank Alice has devised a clever way to secretly embed a message within a sequence of strings that she is trying to send to Bob. Before sending the message, she and Bob agree on a shared...

  • Do this using the C language. show me the code being executed and also copy and...

    Do this using the C language. show me the code being executed and also copy and paste the code so i can try it out for myseld Instructions A cipher is mirrored algorithm that allow phrases or messages to be obfuscated (ie. "scrambled"). Ciphers were an early form of security used to send hidden messages from one party to another. The most famous and classic example of a cipher is the Caesar Cipher. This cypher worked by shifting each letter...

  • in C++ Description The purpose of this challenge is to manually manipulate character arrays. This challenge...

    in C++ Description The purpose of this challenge is to manually manipulate character arrays. This challenge converts text in phone numbers to their equivalent values on a phone keypad. Requirements Write a program to decode phone numbers with letters in them. Create a void function decodetext(char after[], char before[]). This function should be case-insensitive. Do NOT cout in this function. Declare a char array to hold a maximum of 50 characters. Ask the user to enter a string. Use cin.getline(char_variable,...

  • This is my assignment prompt This is an example of the input and output This is...

    This is my assignment prompt This is an example of the input and output This is what I have so far What is the 3rd ToDo in the main.cpp for open the files and read the encrypted message? Does the rest of the code look accurate? Programming Assignment #6 Help Me Find The Secret Message Description: This assignment will require that you read in an encrypted message from a file, decode the message, and then output the message to 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