Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Java please CSE1322 Assignment 2 Background: For this assignment, you will code a simple encryption application. The application encrypts words by mapping a list

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

In Java please

CSE1322 Assignment 2 Background: For this assignment, you will code a simple encryption application. The application encrypts words by mapping a list of the twenty-six alphabetic characters to a list of twenty-six corresponding symbols using the lists indices. 5 6 7 0 1 2 3 4 @ # s symbols list 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 + = ? & . 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 0 1 2 3 b c d e alphabets list fghijklm n r V W X Y Z For example, the word Elvis, would encrypt as follows: E -> A > + V -> ; I ->) s -> ] So, Elvis would encrypt to: "+:)] Your task: You will start with the following class definition: C# Java using System; using System.Collections.Generie: import java.util.Scanner; import java.util.ArrayList: class Encryption class Encryption Listc.char symbols = new Listcharo: Listccharo alphabets = new Listharo; ArrayList'). 1 symbols.add("); symbols.add("@'); symbols.add(**): symbols.add('s): symbols.add(""); symbols.add("&"); symbols.add(""); symbols.add(\('); symbols.add('); symbols.add(); symbols.add(); symbols.add(): symbols.add(=): symbols.add(!?): symbols.add(','); symbols.add( 1 ): symbols.add("): symbols.add(' '); symbols.add(0) symbols.add(): symbols.add("). symbok.add(:): symbols.add(:): symbols.add(.): symbols.add(\*): symbols.add(">'); for(char lettere a leuer=2 letter) for(char letter=a':letterc=z:letter++) 1 alphabets.Add(letter): 1 } 1 alphabets add(letter). This creates two lists (2 ArrayLists in Java, and 2 Lists in C#). The first list contains twenty-six symbols (i.e. -@,#,$,%, etc.), one symbol in each cell. The second list contains the twenty-six lower case letters of the alphabet (a - z), one letter in each cell. From there you'll create the following six (6) methods: 1) Add a method return_alphabet which takes in an int (integer) and returns the alphabet stored at that position, i.e. 5 would return | 2) Add a method return_alphabet_index, which takes in an alphabetic character (char) and returns the index (int) of the character in the alphabets list, i.e. a would return 0, b would return 1. 3) Add a method return_symbol, which takes in an int (integer) and returns the symbol stored at that position, i.e. 5 would return & 4) Add a method return_symbol_index, which takes in a symbol (char) and returns the index (int) of the symbol in the symbols list, i.e. I would return 0, @ would return 1. 5) Add a method encrypt_message, which takes in a plain-text string and returns the encrypted version of that string, i.e. Dwags would return $:!") The method should convert the plain-text string to lowercase (hint: Java: .toLowerCase(), C#: Tolower()) The method should process each character in the plain-text string individually, encrypting each character and building a new string of encrypted characters (hint: Java: to CharArray(), C#: ToCharArray(), return_alphabet_index(), return_symbol()) If an invalid alphabet character is found, the following string should be returned: "Error: Invalid Character" 6) Add a method decrypt_message, which takes in an encrypted string and returns the decrypted version of that string, i.e. $:!*] would return dwags The method should process each symbol in the encrypted string individually, decrypting each symbol and building a new string of decrypted characters (hint: Java: toCharArray(), C#: ToCharArray(), return_symbol_index(). return_alphabet()) If an invalid symbol is found, the following string should be returned: "Error: Invalid Symbol" - Driver Program: Create an object of the class Encryption. Prompt the user with the following menu: 1 Encrypt a message 2 Decrypt a message 3 Quit Enter Choice If the user enters 1, prompt the user to enter a message, pass the result to the encrypt message method, and print the returned encrypted string. If the user enters 2. prompt the user to enter an encrypted message, pass the encrypted message to the decrypt message method, and print the returned decrypted string. If the user enters 3, terminate the program. If the user enters any character other than a 1, 2, or 3, the following error message should display: Error Please enter valid input, and the user should be allowed to reenter a valid choice. Sample Output: 1 Encrypt a message 2 Decrypt a message 3 Quit Enter Choice 1 Enter the plain text message: MayTheForceBe With You Encrypted Msg: =!(^&. (#^@^:// 1 Encrypt a message 2 Decrypt a message 3 Quit Enter Choice: 2 Enter the encrypted message: Decrypted Msg: maytheforcebewithyou 1 Encrypt a message 2 Decrypt a message 3 Quit Enter Choice

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

More Books

Students also viewed these Databases questions

Question

KEY QUESTION Refer to Figure 3.6, page

Answered: 1 week ago