Due: Monday, 25 May 2009 (midnight)
In a substitution cipher we have a list of characters or letters to encode. Each letter in the plain text which is found in the list is translated by a fixed number of places to the character some later in the list. (Characters at the end of the list are wrapped around---translated to a character in the front of the list.) Decoding is the inverse function. Characters not in the list are not encoded/decoded.
For example, the command line
java Caesar encode ABCDEFGabcdefg 21387645will transform the input
We the People of the United States, in Order to form a more perfect Union, establish Justice, insure domestic Tranquility, provide for the common defence, promote the general Welfare, and secure the Blessings of Liberty to ourselves and our Posterity, do ordain and establish this Constitution for the United States of America.to the output
Wf thf Pfoplf og thf Unitfe Stbtfs, in Orefr to gorm b morf pfrgfdt Union, fstbclish Justidf, insurf eomfstid Trbnquility, provief gor thf dommon efgfndf, promotf thf Afnfrbl Wflgbrf, bne sfdurf thf ClfssinAs og Licfrty to oursflvfs bne our Postfrity, eo orebin bne fstbclish this Donstitution gor thf Unitfe Stbtfs og Bmfridb.
Notice the command
java Caesar encode ABCDEFGabcdefg 21387645 < Caesar.java | java Caesar decode ABCDEFGabcdefg 21387645will encode and then decode the text resulting in the original input.
Turn in the Java source code for the program using the submission server. The file name should be Caesar.java and the project is asgn03. Be sure your name is in comments at the beginning of your program as required in the standard header for this class. For your convenience, here is a submission form for this assignment.
|
Course=cse2010 Project=asgn03 |