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...
-
The Canada Revenue Agency was recently granted the power to impose new preparer penalties on individuals who have received payment for preparing a tax return in which the taxpayer is found to have...
-
How much of the 100 kJ of thermal energy at 800 K can be converted to useful work? Assume the environment to be at 25C.
-
Consider an economy with two villages populated by two types of risk-neutral individuals. A type 1 individual can invest \($100\) and obtain \($200\) with certainty. A type 2 individual can invest...
-
Which companies spend the most money on advertising? Business insider maintains a list of the top-spending companies. in 2014, Procter & gamble spent more than any other company, a whopping $5...
-
With regards to the differences between a life insurance policy which is "exempt" compared with a policy that is "non-exempt", which of the following statements is/are true? 1. A non-exempt policy is...
-
Q: A Howe scissors roof truss is loaded as shown. Determine the force in members DF, DG, and EG. 1.6 kips 1.6 kips 1.6 kips 1.6 kips 0.8 kip 1.6 kips 0.8 kip6 ft D. H B G L4.5 ft E A K 8 ft 8 ft 8...
-
As a cashier, answer these few questions: 1. What part of my work challenges me? 2. How do I want to be recognized for exceptional work? 3. What part of my work inspire me to give my full creativity...
-
Grand Company owns 20% of the common stock of Canyon Company, and Grand has significant influence over Canyon. Grand acquired its equity interest in Canyon on January 1, 2021. On the date of...
-
Joe has a white cat named Sam. When Joe crosses Sam with a black cat, he gets white kittens and black kittens. When the black kittens are interbred, all of the kittens they produce are black. On...
-
Prepare the following a. The Statement of Profit and Loss for the year ending December 31, 2020 ( 27 marks ) b. The Statement of Financial Position at at December 31, 2020 The following trial balance...
-
Discuss how you will use what we learned in the course in a professional setting. What did you learn that you will find particularly helpful in your future? What websites or sources did you find...
-
The following events took place for Rushmore Biking Inc. during February, the first month of operations as a producer of road bikes: Purchased $600,200 of materials. Used $516,200 of direct...
-
35 Arrow Hospitality prepares adjustments monthly and showed the following at September 30, 2020 ARROW HOSPITALITY Trial Balance September 10, 200 Unadjusted Trial Balance 8 points Account Cash...
-
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...
-
When it comes to translating the financial statements of entities in highly inflationary countries, which of the following approaches makes more sense and why? a. Remeasure using the temporal method,...
-
Why do currency differences affect foreign exchange reporting?
-
Why do German and French approaches to reporting foreign exchange gains and losses differ from those in the United Kingdom?
Study smarter with the SolutionInn App