Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please use java and use breakline method The problem: crypto me Rot 13 is a simple cipher algorithm that takes advantage of the ASCII code

image text in transcribed

image text in transcribed

image text in transcribedPlease use java and use breakline method

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 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 unting 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 BCDE FGHIKLM ROT13 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 uu 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 View Help Tell me ur course you wil nave to cneck in wnicn nair or tne aipnavet tne cnar a is verore adaing 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 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 n' in between. 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

The Millionaire Next Door The Surprising Secrets Of Americas Wealthy

Authors: Thomas J. Stanley, William D. Danko

1st Edition

1589795474, 978-1589795471

Students also viewed these Databases questions