1. Create a class called SecretDecoder 2. Create a main method in SecretDecoder 3. In the...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
1. Create a class called SecretDecoder 2. Create a main method in SecretDecoder 3. In the main method do the following: 4. Create a variable named secretMessage that contains a string of characters representing an encoded message (i.e. ciphertext) Create a variable named plainMessage that will store a string of characters representing the decoded 5. message (i.e. plaintext) 6. Create a variable named cipherType that store a string of characters representing the name of the type of cipher used to encode the secretMessage 7. Create a variable named rot5Cipher that is a two-dimensional array of char and assign to it the cipher data presented in the table above for the "ROT5" cipher. o Row 0 of the 2D array should contain the plaintext chars o Row 1 of the 2D array should contain the corresponding ciphertext chars. o HINT: A 2D array can be declared and initialized in one statement. An example of declaring and initializing a 2D array of int is as follows: char[] [] charArray {{'a', 'b','c'},{'d','e','f'},{'g', 'h', 'i'}}; 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 8. Create a variable named noalphaCipher that is a two-dimensional array of char and assign to it the cipher data presented in the table above for the "noalpha" cipher. o This 2D array should follow the same requirements as the 2D array above o Make sure that you are initializing the array when you declare it and that you are using characters and not String of length 1. 9. Create a Scanner called myScanner that will take console input from the user A PE02.pdf - Adobe Acrobat Pro DC (32-bit) File Edit View Sign Window Help Home Tools PE02.pdf Subscribe 3 / 6 117% ana not String of iengtn 1. 9. Create a Scanner called myScanner that will take console input from the user 10. Print to the console "Enter the secret message: o Make sure to check the "NOTE THE FOLLOWING" section below for important information on formatting. 11. Read the line inputted by the user and assign it to secretMessage 12. Print to the console "Enter the cipher type (i.e. ROT5 or noalpha) : o Make sure to check the "NOTE THE FOLLOWING" section below for important information on formatting. 13. Read the value inputted by the user and assign it to cipherType 14. Determine which cipher should be used by performing a case-insensitive comparison of the cipher type entered by the user to the names of the supported types from above. o If the cipher type entered by the user matches one of the supported types, then * Create a variable named secretChars to store an array of chars and assign to it an array containing the lowercase chars of secretMessage · HINT: You can use String's toLowerCase () and toCharArray () methods for this step * Iterate over each character in secretChars and perform the following steps: I Iterate over each cipher character in the second row of the correct cipher array (i.e. rot5Cipher or noalphaCipher) 8:14 PM P Type here to search 6/3/2021 哈 2 PE02.pdf - Adobe Acrobat Pro DC (32-bit) File Edit View Sign Window Help Home Tools PE02.pdf Subscribe 4 / 6 100% > If the current secret message char matches the cipher char, replace the current secret message char with the plaintext char from the first row of the cipher array. Use the break keyword to stop iterating over the cipher chars since a match has been found. * Once the conversion of secretChars is complete, use the new keyword to create a String from the secretChars array. · For example, if the cipher type is "ROT5" and the ciphertext is "HMJJXJ UneEf", plainMessage should be "cheese pizza" · For example, if the cipher type is "noalpha" and the ciphertext is "1#2292 &4++", plainMessage should be "cheese pizza" . If you are having trouble figuring out how to do this, refer to the String API. The beginning of the documentation contains an example of creating a String from the contents of a char array. * Print the following to the console using a single call to the printf () method, paying close attention to the spacing: cipher type: (cipherType} ciphertext : {secretMessage} : {plainMessage} Plaintext o If the cipher type entered by the user does NOT match one of the supported types, then print the following to the console using a single call to the printf () method, paying close attention to the spacing: cipher type: (cipherType} ciphertext : {secretMessage} ERROR : This cipher type is unsupported NOTE THE FOLLOWING: • Only create ONE Scanner object and reuse it whenever you need to read more input • Prompts and user inputs should be on the same line. Output should each be printed on separate lines. See Piazza clarifications post for examples output. • There are certain String methods that will make these operations much easier. Please refer to the String API and Course Materials. • Only characters present in the cipher should change, so a ROT5 decoding of "HX1331" would be "cs1331". The numbers do not change since they are not mapped for replacement in the ROT5 cipher. • The ciphertext is not guaranteed to be a single word and may be an entire sentence. 8:14 PM P Type here to search 6/3/2021 哈 1. Create a class called SecretDecoder 2. Create a main method in SecretDecoder 3. In the main method do the following: 4. Create a variable named secretMessage that contains a string of characters representing an encoded message (i.e. ciphertext) Create a variable named plainMessage that will store a string of characters representing the decoded 5. message (i.e. plaintext) 6. Create a variable named cipherType that store a string of characters representing the name of the type of cipher used to encode the secretMessage 7. Create a variable named rot5Cipher that is a two-dimensional array of char and assign to it the cipher data presented in the table above for the "ROT5" cipher. o Row 0 of the 2D array should contain the plaintext chars o Row 1 of the 2D array should contain the corresponding ciphertext chars. o HINT: A 2D array can be declared and initialized in one statement. An example of declaring and initializing a 2D array of int is as follows: char[] [] charArray {{'a', 'b','c'},{'d','e','f'},{'g', 'h', 'i'}}; 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 8. Create a variable named noalphaCipher that is a two-dimensional array of char and assign to it the cipher data presented in the table above for the "noalpha" cipher. o This 2D array should follow the same requirements as the 2D array above o Make sure that you are initializing the array when you declare it and that you are using characters and not String of length 1. 9. Create a Scanner called myScanner that will take console input from the user A PE02.pdf - Adobe Acrobat Pro DC (32-bit) File Edit View Sign Window Help Home Tools PE02.pdf Subscribe 3 / 6 117% ana not String of iengtn 1. 9. Create a Scanner called myScanner that will take console input from the user 10. Print to the console "Enter the secret message: o Make sure to check the "NOTE THE FOLLOWING" section below for important information on formatting. 11. Read the line inputted by the user and assign it to secretMessage 12. Print to the console "Enter the cipher type (i.e. ROT5 or noalpha) : o Make sure to check the "NOTE THE FOLLOWING" section below for important information on formatting. 13. Read the value inputted by the user and assign it to cipherType 14. Determine which cipher should be used by performing a case-insensitive comparison of the cipher type entered by the user to the names of the supported types from above. o If the cipher type entered by the user matches one of the supported types, then * Create a variable named secretChars to store an array of chars and assign to it an array containing the lowercase chars of secretMessage · HINT: You can use String's toLowerCase () and toCharArray () methods for this step * Iterate over each character in secretChars and perform the following steps: I Iterate over each cipher character in the second row of the correct cipher array (i.e. rot5Cipher or noalphaCipher) 8:14 PM P Type here to search 6/3/2021 哈 2 PE02.pdf - Adobe Acrobat Pro DC (32-bit) File Edit View Sign Window Help Home Tools PE02.pdf Subscribe 4 / 6 100% > If the current secret message char matches the cipher char, replace the current secret message char with the plaintext char from the first row of the cipher array. Use the break keyword to stop iterating over the cipher chars since a match has been found. * Once the conversion of secretChars is complete, use the new keyword to create a String from the secretChars array. · For example, if the cipher type is "ROT5" and the ciphertext is "HMJJXJ UneEf", plainMessage should be "cheese pizza" · For example, if the cipher type is "noalpha" and the ciphertext is "1#2292 &4++", plainMessage should be "cheese pizza" . If you are having trouble figuring out how to do this, refer to the String API. The beginning of the documentation contains an example of creating a String from the contents of a char array. * Print the following to the console using a single call to the printf () method, paying close attention to the spacing: cipher type: (cipherType} ciphertext : {secretMessage} : {plainMessage} Plaintext o If the cipher type entered by the user does NOT match one of the supported types, then print the following to the console using a single call to the printf () method, paying close attention to the spacing: cipher type: (cipherType} ciphertext : {secretMessage} ERROR : This cipher type is unsupported NOTE THE FOLLOWING: • Only create ONE Scanner object and reuse it whenever you need to read more input • Prompts and user inputs should be on the same line. Output should each be printed on separate lines. See Piazza clarifications post for examples output. • There are certain String methods that will make these operations much easier. Please refer to the String API and Course Materials. • Only characters present in the cipher should change, so a ROT5 decoding of "HX1331" would be "cs1331". The numbers do not change since they are not mapped for replacement in the ROT5 cipher. • The ciphertext is not guaranteed to be a single word and may be an entire sentence. 8:14 PM P Type here to search 6/3/2021 哈
Expert Answer:
Answer rating: 100% (QA)
package Security import javautilScanner Defines class SecretDecode public class SecretDecode main method definition public static void mainString s To store secret message String secretMessage To stor... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
Create a class called Heater, that contains four fields, temperature, increment, max and min, all of whose type is double. Make sure you write a description of your new Class in the comments, with...
-
Create a class called Vehicle that will hold a string Medium and int Wheels as public properties. Create a class called Car that is derived from Vehicle and contains a Make property and a Model...
-
Create a class called Printer and a class called Job that will simulate a computer printer. The printer should store a queue of Job objects until they are printed. Each Job should consist of a title...
-
State whether the following statements are true or false. Also, very briefly mention the reason if the statement is false. i. TOFO Surfactants increase the surface tension of water. ii. TOFO The Mach...
-
Assume that the data in Case B in Table 2.5 refer to millions of bushels of wheat and millions of yards of cloth. (a) Plot on graph paper the production frontiers of the United States and the United...
-
Sarah Beth's Art Supply Company produces various types of paints. Actual direct manufacturing labour-hours (DMLH) in the factory that produces paint have been higher than budgeted hours for the last...
-
I spent time with you. It seems that this deed is out of character for you. You were not awarded your normal annual bonus. I would probably feel the same. Is that what happened? You normally wouldnt...
-
The general ledger of Pipers Plumbing at January 1, 2015, includes the following account balances: The following is a summary of the transactions for the year: a. Provide plumbing services for cash,...
-
Give the steps required to use the Oracle Enterprise Manager to monitor the performance of the Oracle Database and identify any potential performance bottlenecks.
-
On May 2, 1988, Hannah Weather (Social Security number: 111-22- 3333) acquired residential real estate for $450,000. Of the cost, $100,000 was allocated to the land and $350,000 to the building. On...
-
As part of risk assessment procedures for an audit of a nonissuer, an auditor would most likely perform which of the following procedures concerning related-party transactions? A. Evaluate the...
-
AGRICULTURE. BP Farms is a 300-acre farm located near Lawrence, Kansas, owned and operated exclusively by Bill Pashley. For the upcoming growing season, Bill will grow wheat, corn, oats, and...
-
what ways does cultural diversity serve as a catalyst for creativity, innovation, and cross-cultural fertilization, enriching intellectual discourse, fostering intercultural dialogue, and challenging...
-
Read Book: Baumgardner, Jennifer and Amy Richards. Manifesta [10th Anniversary Edition]: Young Women, Feminism, and the Future Chapters one and two Then answer: 1) Why do you think the authors start...
-
Watch one of the movies listed below and make your own analysis on how it was claimed to be based on/inspired by/related to Plato's Allegory of the Cave. Please explain your analysis clearly....
-
How can innovative technological solutions, such as carbon capture and storage, renewable energy systems, and climate engineering techniques, complement traditional mitigation strategies to achieve...
-
Sole proprietorships Multiple Choice create unlimited liability for their owners. can have multiple owners. are expensive to set up. are faced with double taxation of profits. provide limited...
-
You are a U.S. investor who purchased British securities for 2,000 one year ago when the British pound cost U.S. $1.50. What is your total return (based on U.S. dollars) if the value of the...
-
Let A be a nilpotent matrix (that is, Am = 0 for some m > 1). Show that = 0 is the only eigenvalue of A.
-
Classify each of the quadratic forms in Exercises 1-3 as positive definite, positive semidefinite, negative definite, negative semidefinite, or indefinite. 1. 2. 3. - 2x2 - 2y2 + 2xy xi 2x2
-
a. Prove that a graph is bipartite if and only if its vertices can be labeled so that its adjacency matrix can be partitioned as b. Using the result in part (a), prove that a bipartite graph has no...
-
If 25 women are randomly selected, find the probability that the mean of their red blood cell counts is less than 4.444. Assume that red blood cell counts of women are normally distributed with a...
-
Find the probability of an IQ less than 85.
-
What percentage of women have red blood cell counts in the normal range from 4.2 to 5.4? Assume that red blood cell counts of women are normally distributed with a mean of 4.577 and a standard...
Study smarter with the SolutionInn App