Make the following modifications to Shift Encription I
1. use getline to read 1 line at a time from the file
2. read the shift amount from the user. the user. the shift amount should be a number between -25 and 25. a negative shift amount shifts to the left. a shift amount of 0 does nothing. use the modulus operator to keep the shift amount between -25 and 25. if the shift amount is negative add 26 to it. this is how you convert all shift lefts to shift rights.
3. write encripted characters to the encripted file one character at a time.
ShiftEncription 1 code below:
#include
#include #include using namespace std; const char end_of_line = \'\ \'; int main() { cout << \"Please enter input file name: \"; string input_file_name; cin >> input_file_name; ifstream finp(input_file_name.c_str()); if (!finp.good()) { cout << \"We failed to open \" << input_file_name << endl; system(\"pause\"); return 1; } string output_file_name = \"encrypted\" + input_file_name; ofstream fout(output_file_name.c_str()); int char_count = 0; int line_count = 0; char plain, cipher; while (finp.get(plain)) { char_count++; if (isalpha(plain)) { plain = tolower(plain); // replace \"cipher = plain\" by statements that shift plain by one position to the right into cipher //e.g. b becomes c ... m becomes n ... q becomes r ... y becomes z and z becomes a //convert the letter to a number - number = static_cast(letter) //add 1 to the number and convert it back to a letter //number = number + 1 //letter = static_cast(number) //this methods for all letters but 1 //cipher = plain; int number = static_cast(plain); if(number == 122) number = 97; else number = number + 1; cipher = static_cast(number); } else { if (plain == end_of_line) line_count++; cipher = plain; //we encrypt letters only } fout << cipher; } cout << input_file_name << \" contains \" << char_count << \" characters\" << endl; cout << input_file_name << \" contains \" << line_count << \" lines\" << endl; system(\"pause\"); return 0; }