C++ program that reads text from a file and encrypts the file by adding 3 to the ASCII Solved

30.00 $

Category:

Description

5/5 - (1 vote)

Write a C++ program that reads text from a file and encrypts the file by adding 3 to the ASCII value of each character.
See section 5.11 in Starting out with C++ for information on reading and writing to text files.
Your program should:
1. Read the provided plain.txt file one line at a time. Because this file has spaces, use getline (see section 3.8).
2. Change each character of the string by adding 3 to it.
3. Write the encoded string to a second file, such as coded.txt
4. The encoded file should have the same structure as the original file, if the second line of the original file has 24 characters (including spaces) then there should be 24 characters on the second line of the encoded file (spaces will now look like ‘#’).
Hints:
1. In Visual Studio Express, put your plain.txt file in the project directory. The same folder that your C++ source (.cpp) file is in.
2. One of the challenges is to keep reading lines from the plain.txt file until the end. Sections 12.4 and 12.5 describe how you can do that.
Note that no Raptor program is required for Lab #10. You should, however, think through the structure of the program using a flowchart or pseudo code before starting to write the C++ code. If you want to try this in Raptor be aware that reading and writing files is handled differently in Raptor than in C++. Once your program executes correctly, upload your .cpp file only. Make sure your name is ***** ***** source code in a comment.
Below is what should be encoded.
This is a sample input file for COSC 1436
assignment #10. Your program should encode this
file by adding three to the ASCII value of each
character in it. In your encoded file the first character should
be ‘W’. The last character of the first line should be ‘9’.
The encoded file should have 8 lines of text just like this one,
but will be unreadable. The last character of the last line will
be a ‘1’.

  • LAB10.zip