For each of the following problems, write up your answers on paper (or use a word processor). Remember that the answers you write or type MUST be your own.
Examples:
First string Second string Returned string ABCD EFGH AE AF AG AH BE BF BG BH CE CF CG CH DE DF DG DH ACDC ABBA AA AB CA CB DA DB
TOM,MARGARET,DAVE,TIM,BARBARA,VICTOR,ANGIE,MARK,SCOTT
Write a method that takes a string of comma-delimited names as a parameter and prints out the names in the string, one per line using a Scanner. (HINT: The Scanner class has a useDelimiter method that will be helpful.)
See the instructions online on how to hand in your program electronically. Electronic handin for this assignment will be available starting Thurs by 5:00PM.
Consider the following encryption scheme to encode messages. Create a matrix with the letters of the alphabet as follows:
0 1 2 3 4 0 A B C D E 1 F G H I J 2 K L M N O 3 P Q/Z R S T 4 U V W X Y
Then to encode any letter, create a string consisting of the row number followed by the column number. For example, the letter "G" becomes "11" and the letter "T" becomes "34".
To encrypt a message, first convert each letter to its corresponding two-digit string. For example:
GATES HILLMAN CENTER 1100340433 12132121220023 020423340432Then, using a key word that does not have any repeated letters, create a grid of the digits using the numerical sequence of your converted message such that the number of columns is the same as the length of the key word. For example, if the keyword is CORTINA, we would have:
C O R T I N A 1 1 0 0 3 4 0 4 3 3 1 2 1 3 2 1 2 1 2 2 0 0 2 3 0 2 0 4 2 3 3 4 0 4 3 2
Next, rearrange the grid so that the letters of the key word are in alphabetical order, shifting the corresponding columns of digits along with the letters. In our example, we would get
A C I N O R T 0 1 3 4 1 0 0 3 4 2 1 3 3 1 0 2 2 2 1 2 1 4 0 2 0 2 3 0 3 2 0 4 3 3 4 2
Finally, the message would be written as a sequence of digits, column by column (ignoring the letters at the top of each column):
03043 142022 32220 41204 13123 03233 01104
This is the final encoded message that is transmitted. In order to decode the message, the decrypter would have to work in reverse, as long as he or she knows the secret key word. Without this, cracking this code is much harder (but certainly not impossible).
Write a Java program that reads in a message from the keyboard. After the message is entered, read in a key word. If the key word contains duplicate letters or non-letters, ask the user for another key word until a valid key word is entered. The user may input the message and key word using uppercase and lowercase letters. Convert everything to uppercase and remove all digits and punctuation from the message.
The program should compute the encrypted version of the input message using the algorithm above. You may assume for this assignment that the message, when converted to digits, will be at least as long as its corresponding key word.
Your solution should include methods to perform each of the steps shown above. Define your variables inside of your main method as local variables. Then as you call each of your methods, pass whatever variables are needed to the method. Do NOT define all of your variables as instance ("global") variables to avoid parameter passing.
You should also use standard indentation and variable-naming conventions to make your code easily readable. Finally, you should review each of your methods to see if you are writing redundant or excessive code. Look for places where you can take advantage of patterns to simplify your code. A portion of your programming grade will be based on your coding style.
Once your program reads in the message and the key word, your program should output the original message first in uppercase with spaces but without digits or punctuation, followed by the numerical sequence for the message, then the grid of numbers for the key word before the columns are sorted, then the grid of numbers for the key word after the columns are sorted, and finally the encrypted message as a sequence of digit "words".
You should follow the given guidelines and sample format shown below for maximum credit. Here is a sample run (user input in italics):
Please enter your message: GATES HILLMAN center-6017 Please enter your key word: simpson Please enter your key word: 7UP Please enter your key word: ABBA Please enter your key word: cortina GATES HILLMAN CENTER 1100340433 12132121220023 020423340432 C O R T I N A 1 1 0 0 3 4 0 4 3 3 1 2 1 3 2 1 2 1 2 2 0 0 2 3 0 2 0 4 2 3 3 4 0 4 3 2 A C I N O R T 0 1 3 4 1 0 0 3 4 2 1 3 3 1 0 2 2 2 1 2 1 4 0 2 0 2 3 0 3 2 0 4 3 3 4 2 03043 142022 32220 41204 13123 03233 01104
Remember that you must follow the policies of this course with regard to academic integrity. The work you submit must be your own work and ONLY your own work. You may discuss the problems or Java issues with your class mates or others (e.g. "where did we cover this topic in class?", "how do you write a do/while loop again?", "what does this syntax error mean?", etc.) but when you work on the assignment, you should do your OWN WORK. If you work with a group of friends, try sitting in separate locations when you write your answers so you do not get tempted to work as a group and submit a common or copied answer. Start working early so if you run into trouble, you can come to see the course staff for assistance.
DISCUSSION BOARD: There will be a discussion board set up on Blackboard for the first assignment so you can ask general questions about the assignment or about Java for the course staff or for other students to answer. You should treat the discussion board with the same academic integrity policies outlined above and in the academic integrity policy statement on the course website. Please use appropriate etiquette when writing on the discussion board.
See the course website for instructions on how to hand in your answers and the policy for late submissions.