#include using namespace std; bool GetContinue(); bool GetContinue2(); string Lower(string word); void Lower2(string & word); int GetShiftAmount(); void GetMessage(string & message); int main() { bool keepAtIt{false}; int shiftAmount{0}; string plainText; keepAtIt = GetContinue2(); while(keepAtIt) { shiftAmount = GetShiftAmount(); GetMessage(plainText); /* Encode the plain text message print the crypt text message */ cout << "Encrypting a message " << plainText << " with a shift of " << shiftAmount << endl; //Ask if they want to encrypt a message keepAtIt = GetContinue2(); } return 0; } /* GetContinue: This function asks the user if they wish to continue Input: no input from main Output: returns a bool (yes continue -> true, no don't continue -> false) */ bool GetContinue2() { string answer; bool keepGoing{false}; while( answer != "yes" and answer != "no") { cout << "Do you wish to encrypt a message (yes/no)? "; getline(cin, answer); cout << "answer = " << answer << endl; Lower2(answer); cout << "answer = " << answer << endl; } if (answer == "yes") { keepGoing = true; } return keepGoing; } bool GetContinue() { string input; string answer; bool keepGoing{false}; while( answer != "yes" and answer != "no") { cout << "Do you wish to encrypt a message (yes/no)? "; getline(cin, input); cout << "input = " << input << endl; cout << "answer = " << answer << endl; answer = Lower(input); cout << "input = " << input << endl; cout << "answer = " << answer << endl; } if (answer == "yes") { keepGoing = true; } return keepGoing; } string Lower(string word){ size_t i; cout << "Lower Got " << word << endl; for(i =0; i < word.size(); ++i) { word[i] = tolower(word[i]); } cout << "Lower Returning " << word << endl; return word; } void Lower2(string & word){ size_t i; cout << "Lower Got " << word << endl; for(i =0; i < word.size(); ++i) { word[i] = tolower(word[i]); } cout << "Lower Returning " << word << endl; } int GetShiftAmount(){ return 3; } void GetMessage(string & message){ message = "Hello World"; } int FixNumber(int number) { while (number < 0) { number += 26; } return number%26; } char ShiftLetter(char old, int shift) { int pos = static_cast(old -'a'); char result; pos += shift; pos = FixNumber(pos); result = static_cast('a' + pos); return result; }