Question
Can someone help me with this problem The problem: crypto me Rot 13 is a simple cipher algorithm that takes advantage of the ASCII code
Can someone help me with this problem
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. 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 ASCII 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 ' ' as a new line character. To add it, you will need to break the string first and then concatenate it together again putting ' ' in between. o 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. 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.
Remeber
Do not use numeric or String literals all numbers or Strings must be assigned to variables or constants! Any fixed factor or fixed String used in a computation should be defined as constant. Write meaningful comments for every variable and every step in your solutions make sure to explain what each variables represents. The goal is to make you explicitly reflect about every step in your program. Follow the name conventions for naming your classes, variables and constants.
Step 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