I have the following code and it does compile and cipher. However, if I put in two words (i.e. hello world), it will only cipher hello. If a user inputs two words, as "hello world", I am to omit the space and cipher everything. I thought the isalpha function would do that for me, along with the iteration loop, but it only does the one word.
#include<iostream> #include<string> using std::cin; using std::cout; using std::endl; using std::string; class cypher { public: char apply_cypher(char c); cypher(int key1, int key2); void encode(string answer); private: int a; int b; }; cypher::cypher(int key1, int key2) { a = key1; b = key2; } char cypher::apply_cypher(char c) { char result = ((a*c+B)/> % 26)+97; return result; } void cypher::encode(string answer) { for (std::string::iterator it = answer.begin(); it != answer.end(); ++it){ if (isalpha(*it)){ *it = tolower(*it); *it = apply_cypher(*it); *it = toupper(*it); cout << *it; } } cout << endl; } int main() { int a = 5, b = 8; string answer; cout << "Enter the text you want to cipher:"; cin >> answer; cout << "Cypher:"; cypher cyph(a,B)/>; cyph.encode(answer); return 0; } ~ 51,1 Bot