Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

introductory java language please The problem: crypto me Rot 13 is a simple cipher algorithm that takes advantage of the ASCIl code associated to each

image text in transcribed

image text in transcribed

image text in transcribedintroductory java language please

The problem: crypto me Rot 13 is a simple cipher algorithm that takes advantage of the ASCIl code associated to each character Consider that character letter A' (uppercase) has the code 65, B' is 66, C is 67, and so on until 7 which has the code 90 (see the ASCII table below). Rot13 simply adds 13 to the code of each letter, and if the sum goes beyond the Z' (90), then continues on the 'A' (65). For example to cipher the letter 'R' (82), it sums 13 going beyond 'Z' by 5 and count 5 from Z' to 'A, "B' up to 'E' (82+13 95, Z' is 90, so continues counting 5 more from 'A', 'A' count as1). Since here are 26 letters in the alphabet, the cipher approach is completely reversible. As you can see in the figure at the side, the letters 'A' to M' have a mapping to the letters 'N' to 'Z' and vice versa. A B CD E FGHIK LIM ROT13 HELL ROT13 URYY source: http://en.wikipedia.org/wiki/ROT13 If this explanation is still confusing, please read the Wikipedia article: http://en.wikipedia.org/wiki/ROT13 You need to implement a program that allow the user to encode and decode strings using Rot13. A) Implement the method Bu heed t8 Implement a program that allow the user to encode and decode strings using Rot13. A) Implement the method: public static String rot13 (String input) This method has to perform the encryption as described before. Use a for or while loop to go through the characters in order and convert them by adding 13 to the ASClI code of each character. TIP: in each iteration, you can have something like this: char a- input.charAt (i) a(char) (a 13); Of course you will have to check in which half of the alphabet the char a is before adding 13, because if the letter is in the second half (a >-'n) then you better subtract 13. B) Implement the method public static string breakLines (int maxLength, string text) . This method breaks the text (parameter text) into lines of no more than maxlength size. O TIP 1: you can use 'In' as a new line character. To add it, you will need to break the Review view Help Tell me what you want to d or course you wil nave to cneck in wnicn nair or tne aipnapet tne cnar a is oerore againg 15 because if the letter is in the second half (a >-'n') then you better subtract 1 B) Implement the method public static string breakLines (int maxLength, String text) This method breaks the text (parameter text) into lines of no more than maxLength size. . TIP 1: you can use 'In' as a new line character. To add it, you will need to break the string first and then concatenate it together again putting In' in between. TIP 2: the length of the text divided by maxLength gives you how many times you will have to break a new line. Use a for loop iterating that number of times to do he process. O o You can break the text in any position, not necessarily a blank space. For example, the first break goes in the character at position maxLength. C) Make a program that ask the user to input a text and apply rot13 to it. Use JOptionPane or console to get the input and to display the output If the text to display has more than 50 characters, break it into separate lines (each line of no more than 50 characters). USE THE METHOD breakLines). Make the program keep asking the user to input until the user input 'Q' or 'q', which should terminate the program. TIP: use a while or a do-while loop

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

Data Management Databases And Organizations

Authors: Richard T. Watson

3rd Edition

0471418455, 978-0471418450

More Books

Students also viewed these Databases questions

Question

What is the best long-run business practice?

Answered: 1 week ago

Question

What strategies are available to adjust for non response? Discuss.

Answered: 1 week ago

Question

3. Identify cultural universals in nonverbal communication.

Answered: 1 week ago

Question

2. Discuss the types of messages that are communicated nonverbally.

Answered: 1 week ago