My professor wants us to make a cipher program with in todays. the catch is is that she did not teach us anything about ciphers or how to make them. I feel like ive been tossed into a lion cage help me please :)!
Password Vowels
Substitute Number A a 4 E e 3 I i 1 O o 0 *U u 7
(*As no numbers closely resemble U, just use 7 since it is just above U on the keyboard
intstuctions here
You are required to use “C-Strings” for this assignment. We will further discuss CStrings later in Chapter 12, but you can find an introduction to them in Sections 3.8 and 3.9 of our textbook. A C-String is simply an array of characters like in this example: char word[SIZE];
where word is an array of the char data type with a max length of SIZE. A significant detail, however, in using C-strings is the “null terminating charater”. This character (represented by ‘\0’in a program) is not visible but is used to mark the end of a C-String. You will need to use this to determine when you have reached the end of your password.
In order to receive full credit for this assignment, you must:
1. (5 points) Use a C-string to get the password from the user and complete steps 2 – 4 below in the program. 2. (5 points) Determine how long the password is 3. (5 points) Check every character of the array for a vowel (from the table above). 4. (5 points) Replace all vowels with the substitute number given in the table and then display the newly changed password to the user.
You have presumably studied arrays and basic flow control constructs, which is sufficient for your homework.
What you are being asked to do is transform a piece of text (stored in an array) using a 'substitution cipher' -- replacing one character for another.
Your transform table looks like this: 'A' → '4'
'a' → '4'
'E' → '3'
'e' → '3'
etc.
So you get a 'password' (any text) from the user:
password? Open Sesame
And then your program will take that text "Open Sesame" and replace some of the letters according to the table:
new password: 0p3n S3s4m3
Remember, C-strings are just arrays of characters, where the last character is '\0' (which is just a zero) -- indicating the end of the string. The zero is not counted as part of the text and it is not displayed. You can read more about C-strings in your textbook. Additional reading can be found here: http://www.cplusplus.com/faq/sequences/strings/c-strings-and-pointers/#c-strings
To get a C-string from the user, you need to use a special member function in cin:
1 2 3 4 5 6 7 8 9
int main()
{
constexprint SIZE = 100; // maximum length of a password, minus one (for the '\0')
char users_password[SIZE];
cout << "password? ";
cin.getline( users_password, SIZE );
...