Homework 12: ROT13
Due: Tuesday 12/6 by 1pm
more practice with strings.
Your assignment is to write a program that reads in the user's input and scrambles it using ROT13.
ROT13 is a Caesar Ciper. (See Wikipedia articles on Caesar Cipher and on ROT13.) A Caesar Cipher with shift parameter 3 will replace the letter 'A' with 'D', the letter 'B' with 'E', the letter 'C' with 'F' and so on. Letters at the end of the alphabet wrap around, so the letter 'X' becomes 'A', 'Y' becomes 'B' and 'Z' becomes 'C'. In a Caesar Cipher with shift 3, "DOG" becomes "GRJ".
ROT13 is the Caesar Cipher with shift parameter 13. Thus, 'A' is replaced by 'N', 'B' is replaced by 'O', ... Since the English alphabet has 26 letters, 'N' is replaced by 'A' and 'O' is replaced by 'B'. If you apply ROT13 to a string twice, you get back the original string. For example, ROT13 for "Hello World" is "Uryyb Jbeyq" and ROT13 for "Uryyb Jbeyq" is "Hello World".
Your program should prompt the user for an input string and then print out the ROT13 version of that string. Classwork 25 is a good starting point for your program. (It already reads in a string from the user.)
NotesSome implementation notes:
- Your program should preserve capitalization. That is, 'A' becomes 'N', but 'a' becomes 'n' (lower case).
- Punctuation marks ('.', ',', '?', etc.) should not be changed.
- Numerical digits should not be changed.
SubmittingUse the script command to record yourself compiling and running your program. Run your programs several times with different types of input. Your sample runs should demonstrate the features of your program (e.g., that it preserves punctuation). Submit your C source code and the typescript file as usual:
submit cs104_chang hw12 rot13.c submit cs104_chang hw12 typescript