Answered step by step
Verified Expert Solution
Question
1 Approved Answer
please write the program in introductory Java language using Eclipse The problem: crypto me Rot 13 is a simple cipher algorithm that takes advantage of
please write the program in introductory Java language using Eclipse
The problem: crypto me Rot 13 is a simple cipher algorithm that takes advantage of the ASCII 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 'Z' 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 as 1). 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 CDE FGHIUKLM ROT13ltttii X Y Z NO P Q RSTUVW HELLO ROT13 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: You need to 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 ASCIl 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. 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 n' 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 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 breakLines0). 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 loopStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started