Question: Need Help with this JAVA MAZE RUNNER PROJECT.. Can you please help me with the code and also add comments so I understand the situation..

Need Help with this JAVA MAZE RUNNER PROJECT.. Can you please help me with the code and also add comments so I understand the situation..

A Caesar cipher is a type of rotation cipher, which is a classical way to encode data. The basic idea is that there is an integer key k, and each character in a file is replaced with the character that is k digits away from it. For example, if the key is 5 and the text file begins with A then the first character in the encrypted file will be F because F is five characters away from A. This type of encryption is not actually secure among other problems, it is susceptible to frequency analysis attacks. In fact, rotation ciphers are often used as puzzles for people to solve.

Your goal for this project is to write a program that encrypts and decrypts text files using a Caesar cipher. Your program should contain the following methods with these precise signatures:

public static int getMenuOption()

This program should display a menu with the following options to the user:

1. Encrypt

2. Decrypt

3. Quit

What would you like to do?

The method should read in the users option, verify that it is valid (i.e. that it is either 1, 2 or 3) and then return that option. If the user enters an invalid option, the method should display an error message to the user and reprompt them until a valid option is entered.

public static void encrypt(File inputFile, int key)

This method should accept a text file and key as input and create an encrypted file using the supplied key and the Caesar cipher. Your program should only encrypt files with a .txt extension. The corresponding encrypted file should have the same filename, but the txt extension should be replaced with an enc extension. For example, if the input file is called myTest.txt then the output file would be called myTest.enc. If the user tries to encrypt a file that does not have a txt extension, then your program should display an error message and redisplay the menu. Note that at the ends of the alphabet, the ciphertext character may go outside the bounds of the normal alphabet, into characters like punctuation marks or accented letters. This is completely fine.

public static void decrypt(File inputFile, int key)

This method should accept an encrypted file and key as input and create a decrypted file using the supplied key and the Caesar cipher. Your program should only decrypt files with a .enc extension. The corresponding decrypted file should have the same filename, but the enc extension should be replaced with a txt extension. For example, if the input file is called myTest.enc then the output file would be called myTest.txt. If the user tries to decrypt a file that does not have an enc extension, then your program should display an error message and redisplay the menu.

Your program should have any other methods you feel are necessary for it to operate correctly. Your main method should not do anything significant by itself it should only be a series of method calls with minimal control flow statements (if, switch, or loop constructs) around them.

Your project will be evaluated according to the following rubric. Each item is worth one point.

The getMenuOption method meets the specified requirements

The encrypt method meets the specified requirements

The decrypt method meets the specified requirements

The Caesar cipher is correctly implemented

Invalid user inputs are handled as specified in the requirements

The main method contains only method calls and control flow constructs everything else is done inside the other methods

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!