Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please read the instructions carefully and use dialog boxes for input and output messages( JOptionPane). Thank you. Objective To build a complete working Java program

Please read the instructions carefully and use dialog boxes for input and output messages( JOptionPane). Thank you.

Objective

To build a complete working Java program that offer practice with Java string manipulation.

Overview & Instruction

Write a Java program that performs encryption of a given message.

Your program is designed to send a coded message to an overseas embassy. The message will be a one-line comma-delimited string. The first token of the string should be a three-character code representing the country you wish to communicate with along with a priority code suffix.

The following list includes all possible countries:

FR - France GB - Great Britain

CA - Canada JA - Japan

RU - Russia GE - Germany

AU - Australia MX - Mexico

The following list includes all possible criticality codes:

1 - URGENT

2 - IMPORTANT

3 - ROUTINE

For example, if this part of the message includes GB1, you should use Great Britain in the message header and further indicate that the message is URGENT. The next part of the string will include the message to be delivered to the embassy. This will need to be "encrypted".

Error checking should be included so that any invalid country code or criticality level would push the user into a loop until they enter a correct pattern. Check further to be sure that there is exclusively one comma and that the message following the comma is not blank.

A sample message could be: GB1,It is time for tea

Your encryption routine should:

Convert the message to all uppercase characters

Replace all blanks with underscore characters

Reverse the string

Swap pairs of characters (left-to-right, two at a time)

Exchange the characters of the string with the randomized key string

The key string should be stored in a file (that might change daily in a real-world scenario) that will look like this:

ABCDEFGHIJKLMNOPQRSTUVWXYZ

KQBZCGOAWPMHVLFXEDURIYSJNT

A key file for the assignment is provided here: key.txt

Finally, design your solution using an object oriented approach. This implies a Message class that will include the abilities to validate and manage the country code, criticality index, and to encrypt the message. A suggested design would be to read the user entry into the Message object as it is being constructed.

You output should be one String object ready for transmission in this form:

To Embassy: Great Britain|URGENT|xx_xxx_xxxx_xx

Note the use of the | symbol for delimiters. Note also substring after the last | symbol will be the encrypted message (only a rough sample provided here).

Your main driver application class can then be narrowed to managing the user interaction as well as method calls to the one Message object in the solution. Utilize dialog boxes for both input and output.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Joe Celkos Data And Databases Concepts In Practice

Authors: Joe Celko

1st Edition

1558604324, 978-1558604322

More Books

Students also viewed these Databases questions