Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Complete the following using C++, note that most of the assignment is already completed. All you have to do is complete the Encoding part of

Complete the following using C++, note that most of the assignment is already completed. All you have to do is complete the Encoding part of the assignment. Decoding is already finished. The mostly completed code is all the way at the bottom of this post with a link to the file. Be sure you follow all directions carefully and do the Encoding part correctly. Post a link to the completed file for download once completed.

Your 7 year-old neighbor has just excitedly told you that she has discovered this really neat code which she and her friends are using to send messages to each other. The code, she explains, involves writing a number in place of each letter of the alphabet. The coding equivalences are:

A=1, B=2, C=3, D=4, E=5, Z=26 (your neighbor doesnt worry about lower case letters).

Furthermore, they are using zero for each space between words. Your neighbor, however, says that it takes a really long time to translate her messages into code or to decode the messages she receives from friends, so she is wondering if you could write a computer program to do those jobs for her (and you have agreed!).

Thus, your program needs to first ask if the user is coding or decoding. If coding, it then asks for the messages (letters and spaces only) and in turn prints out a string of numbers that code the messages according to the scheme described above. When encoding, the input message should be converted to uppercase before starting the encoding process; then if any non-legal characters are detected in the input stream during the process, they should be turned into the number 99 when output. To convert the string to uppercase you will use the toupper() function available in the cctype library.

If decoding, accept a series of integer values, each separated by a space; convert the numeric values to their letter and space equivalents. Any numbers that are out of bounds (i.e., not between 0 and 26) should be turned into a ? (question mark) in the output message. A sample run might be:

Welcome to the Letter Code program. I can make a super-secret encoded message from words you give me, or decode a super-secret message you receive from a friend.

Enter choice (ncoding, ecoding, or uit)? E

Enter your message: MEET AT SALLYS TODAY

Your coded message is:

13 5 5 20 0 1 20 0 19 1 12 12 25 19 0 20 15 4 1 25

Enter choice (ncoding, ecoding, or uit)? D

Enter your numbers, separated by a space. Use zero for a space in your message; enter the number 99 at the end of the list:

1 2 3 0 4 5 99

Your decoded message is:

ABC DE

Enter choice (ncoding, ecoding, or uit)? Q

Thanks for using the Letter Code program!

=============================================

Call the program LetterCode.

For the Encode logic in this program you will have to go beyond the simple cin function that we used previously to pull a character value in from the buffer. You should investigate the use of the string class and the global function getline() that can be used to pull a full string of characters from the cin object. You can then manipulate the string using functions of the string class, such as substr().

For the Decode function it is tempting to try to do the same sorts of operations, that is, reading the number list in as a string. If you do that, however, you will have to parse the string to separate the numeric values. This is not so easy in C++, because no split operation is available (as it is in java or vb, for example). Therefore, the above sample shows a decode input that uses the normal cin function inside a loop, which terminates when a sentinel value (99) is seen. The values will be stored in a new type of object, a vector, which is a type of array that does not have a set size.

Code LetterCodeLogic as a separate class:

To complete this assignment you should code a separate LetterCodeLogic a class file to do the actual conversion processes. The class will have two static, public members: Encode and Decode. The Encode function will receive the input string to be encoded from the user and return a string with the numeric conversions (separated by spaces, as shown above)

// Here is the link to the project file. Once again, this assignment is MOSTLY COMPLETE. There is maybe only 10-15 mins of work needed at most.

https://1drv.ms/u/s!AjLswKvo9tl3hCT6qEalO8jd55Af

Once completed, post a download link to the file you've finished, just like above.

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

SQL Server Query Performance Tuning

Authors: Sajal Dam, Grant Fritchey

4th Edition

1430267429, 9781430267423

More Books

Students also viewed these Databases questions

Question

Explain why the long-run aggregate supply curve is vertical.

Answered: 1 week ago

Question

Calculate the total current from the 9-volt battery. 60

Answered: 1 week ago

Question

U11 Informing Industry: Publicizing Contract Actions 317

Answered: 1 week ago