Question: NEED ASAP WRITTEN IN JAVA This question was also discussed in class. Review the slides (see above) prior to working on this problem. The problem

NEED ASAP WRITTEN IN JAVA

This question was also discussed in class. Review the slides (see above) prior to working on this problem. The problem is essentially an encoding/decoding problem losely based on the German Enigma machine used during WWII. This is the code that Allan Turing and his colleagues broke. The movie "The Imitation Game" gives a fairly good historical account of this enterprise.

For this problem you pick a 3-letter English word and encode each letter in the 3-letter word randomly, using one of the 26 letters of the alphabet.

Requirement:

1. You pick the word you want to encode. Show the word in a small window labeled "original word" (this is not user input. it is only for showing the word you picked).

2. Make two more small windows. One where you show the encoded word and another where you show the decoded word so it can be compared to the original.

3. Have a simple GUI with an encode button to start the program and a decode button to decode

4. Print the the encoded word after the encode button is pushed and print the decoded word when the decode button is pushed and the program terminates..

5. Write a timer that measures the number of milliseconds it took to decode. (you may use a window for that as well)

JAVA Encoder and code breaker.

Instructions:

First do some background reading on the Enigma machine, using the links below. Be sure to try the Enigma simulator and watch the videos to get a feel for the complexity of the encoding that Enigma was capable of.

http://www.quora.com/How-did-Alan-Turing-figure-out-the-Enigma-machine

http://enigma.louisedade.co.uk/index.html

Next you will develop an encoder in JAVA

Write down some English 3-letter word.

Here are some Examples: Get, sun, and, can, saw, dog, one, two, six, old, ten, for, you, end.

Type a few of these 3-letter words into the Enigma simulator.

Next design a JAVA program that does the following:

It allows the user to input a three letter word.

It saves this word in an array / string.

Then the program randomly picks a letter from the 26 letters of the alphabet and uses that letter to replace the first letter of the 3-letter word.

The program checks if the randomly selected letter matches the first letter of the 3-letter word. If it does not, the program proceeds to the next letter and replaces it with a letter randomly selected from the 26 letters of the alphabet;

If the randomly selected letter matches the first letter of the 3-letter word, the program randomly selects another letter and repeats that process until the randomly selected letter is different from the first letter of the 3-letter word.

The same process is repeated for the next two letters of the 3-letter word.

At this point you have an encoded 3-letter word. For example let us say the original word was dog (without the quotes. This could have been encoded variously as: mii, laz, fqy, zlp.

Save the encoded word.

Remember: A copy of the original word must also be saved.

Now comes the fun part: Write code that does the following:

For the first letter of the encoded word, each of the 26 letters of the alphabet is substituted. This would yield 26 3-letter strings. Check if any of the 3-letter strings (words) thus generated match the original word that was encoded.

Now, for each of the 26 3-letter strings, take the second letter and substitute each of the 26 letters of the alphabet. You now have made substitutions for the first two letters in the encoded 3-letter word. This would yield 26 * 26, or 626 new 3-letter strings (words). Check if any of the 3-letter words thus generated match the original that was encoded.

For each of the 626 3-letter strings, take the last letter in the string and substitute each of the 26 letters of the alphabet for the last letter in the 3-letter string. This would yield 17,576 3-letter strings (words). Check if any of the 3-letter words thus generated match the original that was encoded. One has to match.

When the match is found print this message:

A match has been found. The original word was: x x x . (In place of xxx, print the original word, which in this example was dog)

Now modify the program, so a timer starts right after the user inputs the 3-letter word and stops right after the message A match has been found. The original word was: x x x . (In place of xxx, print the original word, which in this example was dog) is printed.

Next modify the program so it can handle 4-letter words. How much time does it take to break the code for a 4-letter word?

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 Databases Questions!