Hi I am fairly new to C++ programming, but my professor has given us a project that I feel is beyond our scope of what we have learned.
The problem is to write a program that creates a cryptogram out of a string. Note that spaces are not scrambled. Uppercase letter should be treated the same as lowercase letters. Well this is the program that I wrote going with the example in our book, but he says that, it is completely wrong and that he wants a cryptogram program that asks for the input of a string and no matter what is entered it will encrypt it. So now I am completely lost and there is nothing in our book that goes beyond what my program does. Can any one help me?
#include <iostream>
using std::cout;
using std::endl;
#include <string>
using std::string;
int main()
{
//compiler concatenates all parts into one string
string s ( "see spot run");
cout <<"Original string before any replacements:\n"<<s
<<"\n\nAfter replacements:\n";
//replace all letters with other letters
int x = s.find("s");
while (x<string::npos) {
s.replace( x,1, "b");
x = s.find ("s", x+1);
int x = s.find ("e");
while (x<string::npos) {
s.replace(x,1, "j");
x = s.find ("e", x+1);
int x = s.find ("p");
while (x<string::npos){
s.replace(x,1,"m");
x = s.find ("p", x+1);
int x = s.find ("o");
while (x<string::npos){
s.replace(x,1,"z");
x = s.find ("o", x+1);
int x = s.find ("t");
while (x<string::npos){
s.replace(x,1,"k");
x = s.find ("t", x+1);
int x = s.find ("r");
while (x<string::npos){
s.replace(x,1, "q");
x = s.find ("r", x +1);
int x = s.find ("u");
while (x<string::npos){
s.replace(x,1, "c");
x = s.find ("u", x +1);
int x = s.find ("n");
while (x<string::npos){
s.replace(x,1, "a");
x = s.find ("n", x +1);
}
}
}
}
}
}
}
}
cout <<s<< endl;
return 0;
}