Question: Objective To build a complete working Java program that offers practice with Java string manipulation. Overview & Instruction Write a Java program that performs encryption

Objective To build a complete working Java program that offers practice with Java string manipulation. Overview & Instruction Write a Java program that performs encryption of a given message. You are writing a solution for intelligence officers in hostile nations that must send a coded message back to Washington, DC. The encryption must be unbreakable. Your program will receive the following as input: message destination, criticality level, and message content. An example is P1,WE ARE OUT OF COFFEE The message will be a one-line comma-delimited string. The first token of the string should be a one-character code representing the destination the message, the second character is a priority code. Then, following only one comma the remaining text is the message you wish to encrypt and send.. Once the message is encoded, your ultimate program output would be something like the following format: To: Pentagon (URGENT) Message: xxxxxxxxxxxxxxxxxxxx Your encryption routine should: 1. Convert the message to all uppercase characters 2. Remove all blanks spaces 3. Reverse the string 4. Shift the characters (not underscores) to the "right" based a key read in from an external file. See below. The key will be a two-digit number read in from an external file. This simulates that the key would be a changeable feature. The sender and receiver would know the key. For example, if the key was 25 on a given day: shift first character two position, the second character five positions, the third character two positions, the fourth character five positions, and so on. Be sure to "wrap" a character A..Z if it rolls off the alphabet. For example, if a Y was to be shifted "to the right" 5 places, it should wrap to a D. Note: To implement this feature, create a simple text file keyshift.txt and save a two-digit number within it. Below are specifications related to the destination and criticality codes. The following list includes all possible message destinations: P - Pentagon W - White House N - National Security Agency C - Central Intelligence Agency The following list includes all possible criticality codes: 1- URGENT 2- IMPORTANT 3- ROUTINE Design your solution using an object oriented approach. This implies a Message class with at least the following features: Data members: Message Destination code Criticality code Constructor that: Receives a message string Parses (breaks up) the string to extract and store the destination and criticality codes A method encrypt() that performs the required encryption algorithm and returns the encrypted message string. This method should also manage the keyshift.txt file. A validation method that checks the following: The string has exactly one comma with two characters before the comma and at least one after. The destination code and criticality code are both valid. Methods to return the destination name and criticality description strings Your (main) driver application class can then be narrowed to managing the (very simple) user interaction as well as method calls to the one Message object in the solution. Include the following tasks: Prompt the user (via dialog boxes) for the input string. Instantiate the Message object with the input string If the Message object is valid (i.e. "ask the object" if it is valid using the validation method), Encrypt the message "Get" the encrypted message destination string and criticality string Formulate the output message and display via a dialog box Otherwise, provide a dialog to the user that the message input was invalid. Finally, note that there is no requirement for code decryption (decoding). Also, remember that Java String comparison requires use of the equals() method instead of ==.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!