Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

ROT13 (rotate by 13 places) is a simple letter substitution cipher that is an ex

ID: 3666591 • Letter: R

Question

ROT13 (rotate by 13 places) is a simple letter substitution cipher that is an example of a Caesar cipher used by Julius Caesar. ROT13 replaces a letter with the letter 13 letters after it in the alphabet. (A==>N, B==>O, C==>P, etc...) So, the translation of the word COMPUTER using ROT13 would be PBZCHGRE.

Write a C++ program that asks the user for the name of an input file and translates the contents of that file using ROT13. Your program should also save the results of the translation into another file with a ".rot13" file extension.

Explanation / Answer

#include #include #include using namespace std; //pre: none //post: returns true if the parameter is alphabetic, false otherwise bool alphabetic(char ch); //pre: array has been declared, size has been initialized //post: user has been prompted for input. array has up to fifty characters accepted from keyboard. Size contains the number of characters stored in the array. void fillArray(char array[], int& size); //pre: array has been declared, size has been initialized to the size of the array //post: array has been encrypted according to this algorithm: void rot13(char array[], int size); //pre: none //post: returns true if the character is from the first half of the alphabet, false otherwise bool firstHalf(char ch); int main () { char a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z; bool goodinp; fillArray (size); goodinp = alphabetic (ch); if (goodinp) { a = 0; b = 1; c = 2; d = 3; e = 4; f = 5; g = 6; h = 7; i = 8; j = 9; k = 10; l = 11; m = 12; n = 13; o = 14; p = 15; q = 16; r = 17; s = 18; t = 19; u = 20; v = 21; w = 22; x = 23; y = 24; z = 25; } bool alphabetic(char ch) { char 'a' bool character = true; if (ch != a) { character = false; return 0; } } void fillArray(char array[50], int& size) { cout cin>> size; }