Question: Before you begin, review the module topic More Reading from a File. There are some great examples that can help you get started. Be careful
Before you begin, review the module topic "More Reading from a File". There are some great examples that can help you get started. Be careful to select the correct data type when creating a variable to store your file's input. The examples from that module topic will just get you started, but does not meet the requirements of the project, so read the requirements carefully before submitting your code.
If you have problems reading from a file, check out the module topic "Where Is the File Supposed to Be for help with setting up your project on some IDEs.
For this project, download these files:
encode.cppDownload encode.cpp
decode.cppDownload decode.cpp
These files contain functions that you will need to include in a program that can be used to:
Encode the contents of a file and store the coded message in a separate file
Decode a message from a file and store the plain text in a separate file.
Do not write your own C code to encode or decode the message. That code is provided for you in the cpp files listed above. You can add the cpp files to your IDE project or copy and paste the contents to your own cpp file, but you must use these functions without modification.In other words,you must not modify the CaesarEncode function or the CaesarDecode function in any way.
Important Note: The CaesarEncode or CaesarDecode functions must be called for each character you wish to encode or decode. So you must pull a single character from the input file and send it to the appropriate function as an argument in the parentheses when you call the function. For help in reading a single character from a file, check out the module topic: My Favorite InputOutput TutorialLinks to an external site.
main Function
The main function will handle all user interaction, including:
Welcome the user
Ask the user if they would like to encode or decode a message. Store the response in a variable called encodeDecode
Ask the user for the input filename
Ask the user for the output filename
Ask the user for an integer key value this will be used to encode or decode the message
call the processFile function and pass the input filename, the output filename, the integer key value and the encodeDecode variable
processFile Function
The processFile function is required. If you put all of your code in the main function, you will lose points automatically. The processFile function will handle input and output operations only. User interaction must be done in the main function.
For this function, you will need an input file. For testing purposes, you can use any file from Module topics or provide your own file. The file of your choosing will be used as an input file in your program.
Your processFile function will:
Create an ifstream named inFile connecting your program to inputFileName.
Create an ofstream named outFile connecting your program to outputFileName.
Check that inFile opened correctly. If not, return false.
Use a loop to read the input file. Inside the loop, perform the following:
Read a single character from the fileCall the appropriate function to either encode or decode the message.
if the encodeDecode parameter indicates encode, call caesarEncodeif the encodeDecode parameter indicates decode, call caesarDecode
Write the return value of the function into a separate output file.
When file operations are complete, close all ifstream and ofstream connections.
Requirements
Your program must have a minimum of functions:
main points Handle all user interaction, call processFile and pass user input as arguments
CaesarEncode This function is provided in the cpp file above
CaesarDecode This function is provided in the cpp file above
processFile points This function will perform the tasks described above. This function must have four parameters one for each user input including:
inputFileNameoutputFileNameencodeDecodean integer key variable.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
