Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

C++ QUESTION: You will be provided with an input file that has a series of encoded messages. You will need to read in the file

C++ QUESTION:

You will be provided with an input file that has a series of encoded messages. You will need to read in the file and decode the messages. You must check to make sure that the input file has been opened. If not, you need to print Input File unable to open. to the output file.

The first 26 lines of the input file will tell you what each coded letter should equal. For example: A = Z means that for every A in a coded message, it should be replaced with a Z. You should store this information in an array for easy decoding. This set of information will always be presented A through Z so that you may assign an array position to a letter, i.e., index 0 will always be A.

The next number in the file will be the number of coded messages that will be contained in the file. This number should be used to make a dynamic array of the structs (i.e., the number is the size of the dynamic array).

You will need to create a struct that contains an integer type of variable that keeps track of which message number is contained in the struct, and two strings, the coded message and the decoded message.

struct messages{

int messageNum;

string codedMessage;

string decodedMessage;

};

Then, using the getline function, you should read in a whole line of the file at a time and store it in the appropriate struct location (i.e., the string member variable of the struct used to store the coded message). You will then decode the message and store it in the appropriate struct location. A function is recommended for decoding, but not required.

Once all the messages are decoded, you should go over the dynamic array and print each element with its corresponding message number, the coded message, and the decoded message, to the file out.txt?.

Implement a class Message that stores the dynamic array of struct messages as its private member attribute.Implement member functions to add, decode and print messages. Additionally, you should implement appropriate constructors and destructors that are responsible for initializing and deallocating the dynamic array.

This class should be implemented using separate header and cpp files, message.cpp? and message.h?. Therefore, if you are attempting the bonus, you must leave all 3 files in your home directory.

This is the sample output

image text in transcribedimage text in transcribed

The following is the message seen on your screen: Please enter the input file name with its extension: testinput.txt Process finished with exit code 0 Input: testinput.txt testinput.txt A=Z 7 c=x G=T H=S L=0 M=N N=M P=K R=1 T=G U=F w=D Y=B SLD NZMB KILTIZNNVIH WLVH RG GZPV GL XSZMTV Z ORTSG YFOY? MLMV, GSZG'H Z SZIWDZIV KILYOVN 6

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_2

Step: 3

blur-text-image_3

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

Database Internals A Deep Dive Into How Distributed Data Systems Work

Authors: Alex Petrov

1st Edition

1492040347, 978-1492040347

More Books

Students explore these related Databases questions