Lab #9 (10 points) Due: Thursday, May 4

1. Write a program that reads in a sentence, then prints it out in reverse order. For example, the program should display uoy evol I for the input: I love you Your class should include 3 methods:  obtain, which reads the original sentence  report, which prints out the reverse  main, which tests the other two methods 2. Add a method that displays the characters in the input sentence (including spaces) as their numeric ASCII values. For example, the input “I love you” would produce the output:

73 32 108 111 118 101 32 121 111 117

Modify your main method so that it tests your new display method (don’t replace the old one!). 3. Add one more method, which implements a Caesar cipher on your text. The Caesar cipher works by shifting each letter of the text N positions up in the alphabet, where N is some integer. The example below shows the uppercase letters of the English alphabet shifted 5 positions:  original: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z  enciphered: F G H I J K L M N O P Q R S T U V W X Y Z A B C D E Note that the alphabet "wraps around" once it reaches the end – thus, V maps to A, W maps to B, and so forth. The message "I LOVE YOU" enciphered in this fashion would be: N QTAJ DTZ You method should:  prompt the user for N  Display the message with each letter shifted N positions; keep the spaces and the case intact – this means that you will have to be sure that both versions of the alphabet wrap appropriately. 4. Modify your main method so that it contains a loop that:  Displays a menu describing the three encryption options and a quit option  If the user chooses an option other than quit, prompts for an input String and calls the appropriate method  Continues this process until the user chooses to quit.

Turn in a printout of your source code (with your name on it!).

Computer Science I Spring 2006 Sheller Page 1 cs1s06lab9(charstrings) - work