Access over 20 million homework & study documents
search

A cryptogram is a message that is encoded by replacing each letter i

Content type

User Generated

Rating

Showing Page:
1/10
A cryptogram is a message that is encoded by replacing
each letter in a message by another. In the original
message, all occurrences of a single letter are
all replaced by the same new letter in the encoded
message. Additionally, there is a one-to-one mapping
between letters in the original message and letters in
the encoded message. This means that no two different
letters in the original message are replaced with the same
letter.
You are going to write a program that allows the user to
type in an encoded cryptogram message. The user will
then be able to try to decode the message by replacing
letters one at a time in the message until the message is
completely decoded. In this program, you will need one
class named Cryptogram that will use ArrayLists or
(Vectors) to store the messages. You will also provide a
MissingLetterException class and a InvalidInputException
class for input errors.
SETUP
Use two ArrayLists or (Vectors) of Character objects to
store the characters of the encoded message and the
decoded message respectively. The encoded message
will NOT be read in from the keyboard. You are to store
the encoded message directly in the program as a
\"constant\" (this is done to simplify grading). You can do
this by defining a String object that is initialized to the
encoded message. Then add each character of the
message into an ArrayList (or Vector). Set up the second
ArrayList (or Vector) so that it is an exact copy of the
encoded message, except that each letter is replaced with
an asterisk (*). For example, here is the encoded
message you will be using:
Encoded Message: X AQC\'M YCQO OKJM BQG OJCM
DGM X SJC\'M WXZP XM JCB TQVP
Decoded Message: * ***\'* **** **** *** **** *** * ***\'* ****

Sign up to view the full document!

lock_open Sign Up
Showing Page:
2/10
** *** ****
Note that non-letters are not encoded (e.g. the quote).
INPUT & OUTPUT PROCESSING
Input will come from the keyboard in this program. The
user will enter a letter from the encoded message, and
then the user will enter what to change the letter to
in the original message. For example, it might look like
this (user input in purple):
Pick a letter from encoded message: M
Replace with which letter (A-Z,*): S
Encoded Message: X AQC\'M YCQO OKJM BQG OJCM
DGM X SJC\'M WXZP XM JCB TQVP
Decoded Message: * ***\'S **** ***S *** ***S **S * ***\'S
**** *S *** ****
The user may replace a letter with an asterisk (*). For
example, the next input might look like this (user input in
purple):
Pick a letter from encoded message: M
Replace with which letter (A-Z,*): *
Encoded Message: X AQC\'M YCQO OKJM BQG OJCM
DGM X SJC\'M WXZP XM JCB TQVP
Decoded Message: * ***\'* **** **** *** **** *** * ***\'* ****
** *** ****
The user will continue to decode the message, one letter
at a time. If the decoded message has NO ASTERISKS,
you should ask the user if the message is decoded. If
it is, your program should end. Otherwise, it will continue
to ask for letters.
EXCEPTION PROCESSING
If the user inputs a letter not in the encoded message, you
should throw a LetterMissingException. The exception
handler should report the error and prompt the user
for another letter until the user finally enters a letter in the
encoded message. If the user inputs a character for the
decoded message that is not a letter or an
asterisk, you should throw a InvalidInputException. The

Sign up to view the full document!

lock_open Sign Up
Showing Page:
3/10

Sign up to view the full document!

lock_open Sign Up
End of Preview - Want to read all 10 pages?
Access Now

Unformatted Attachment Preview

A cryptogram is a message that is encoded by replacing each letter in a message by another. In the original message, all occurrences of a single letter are all replaced by the same new letter in the encoded message. Additionally, there is a one -to-one mapping between letters in the original message and letters in the encoded message. This means that no two different letters in the original message are repla ced with the same letter. You are going to write a program that allows the user to type in an encoded cryptogram message. The user will then be able to try to decode the message by replacing letters one at a time in the message until the message is completely decoded. In this program, you will need one class named Cryptogram that will use ArrayLists or (Vectors) to store the messages. You will also provide a MissingLetterException class and a InvalidInputException class for input errors. SETUP Use two ArrayLists or (Vectors) of Character objects to store the characters of the encoded message and the decoded message respectively. The encoded message will NOT be read in from the keyboard. You are to store the encoded message directly in the program as a \"constant\" (this is done to simplify grading). You can do this by defining a String object that is initialized to the encoded message. Then add each character of the message into an ArrayList (or Vector). Set up the second ArrayList (or Vector) so that it is an exact copy of the encoded message, except that each letter is ...
Purchase document to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Anonymous
Nice! Really impressed with the quality.

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4