Question: /* * Program to encrypt content of a file * * Name: * Date: February 13, 2021 */ #include #include #include using namespace std; bool

 /* * Program to encrypt content of a file * *Name: * Date: February 13, 2021 */ #include #include #include using namespacestd; bool islower(char p) { // function to check if a character

/* * Program to encrypt content of a file * * Name: * Date: February 13, 2021 */ #include #include #include

using namespace std; bool islower(char p) { // function to check if a character is a lower case character or NOT

if (p >= 'a' && p

// Main cout

cin >> choice >> fname; // Open file ifstream inFile(fname); inFile.get(c);

if (choice == 1) { while (!inFile.eof()) { cout

return 0; }

So this is mostly the same code I wrote for last weeks assignment. I added the WHILE NOT eof statement hoping it would go through the loop until the file finished but it's not seeming to do anything. I've been staring at it for days and don't see why it wouldn't loop back through.

Description: This program is part 2 of the Encryption program. You should be building on last week's Encrypt.cpp . For this part, process all characters in the file instead of just the first Make sure that for choices 2 and 3, you do not use an if, else, or loop to do the shifting Here's the logic of how to do it: Think of the alphabet as a circle. After Z comes A. TILLS There are 26 letters in the alphabet. The % (mod operator) gives a remainder. If you mod any number by 26, you will get a number between 0 and 25. This is a common technique for using circular buffers. If we could take a numerical version of a letter (O for A, 1 for B, and so on), then we could add/subtract and mod by 26 (the size of our circular buffer) to rotate around the alphabet (circular buffer) - If you have a negative number and use %, you will get a negative number. We don't want that. We want to stay between 0 and 25. . When we shift forward and add 3, there are no issues - When we shift backward and subtract 3, it is possible to get a negative number. We can add 23 instead of subtracting 3. If we are traveling the circle, subtracting 3 is the same as adding 23 Now our next issue is that the ASCII values of 'a' to 'z' are not 0 to 25. Instead they are 97 to 122. We need the numbers to be 0 to 25 when doing the addition and mod-ing. This can be easily accomplished by subtracting 97 (or 'a') from the letter Overall, we need to shift the letters from 97 through 122 down to 0 to 25, add 3 (or 23), mod by 26, and then shift the result back into the range of 97 to 122. The total process for adding 3 is something like (not exact C++ syntax): shifted Down = letter - 'a' - mod Letter = (shifted Down+ 3) mod 26 shifted Up = modLetter + 'a' Add 2 additional encryption choices: Choice 5 - Duplicate every other letter. For example, "abcd" becomes "aabccd". Choice 6 - This is the opposite of choice 5. Change "aabccd" back to "abcd". file4.txt has the following contents: xyz abc def ghi jkl mno par stu vw file5.txt has the following contents: A-bba cc 2 file6.txt has the following contents: bba cc xyyz Sample Run #1 (bold, underlined text is what the user types): ? 1 file4.txt abc def ghi jkl mno pqrstu vw Sample Run #2 (bold, underlined text is what the user types): ? 2 file4.txt abc def ghi jkl mno par stu vwxyz Sample Run #3 (bold, underlined text is what the user types): ? 3 file4.txt UVW xyz abc def ghi jk1 mno par st Sample Run #4 (bold, underlined text is what the user types): ? 4 file4.txt 47 Sample Run #5 (bold, underlined text is what the user types): ? 5 file4.txt XXyzz abbc ddeff ghhi jjkll mono pparr sttu vvw

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!