3A.
Provide a written response that does all three of the following:
i. Describes the overall purpose of the program
ii. Describes what functionality of the program is demonstrated in the video
iii. Describes the input and output of the program demonstrated in the video
?
The purpose of this program is to take a word or phrase and encrypt it using a Caesar Cipher. The video demonstrates the user entering a phrase in and the encrypted phrase being printed out. In the video, you can see 2 different inputs. The first input is the un-encrypted phrase and the second input is the number of characters to shift the letters. You can also see the program output the encrypted phrase.
3B.
Capture and paste two program code segments you developed during the administration of this task that contain a list (or other collection type) being used to manage complexity in your program.
i. The first program code segment must show how data have been stored in the list.
ii. The second program code segment must show the data in the same list being used, such as creating new data from the existing data or accessing multiple elements in the list, as part of fulfilling the program’s purpose.
Then, provide a written response that does all three of the following:
iii. Identifies the name of the list being used in this response
iv. Describes what the data contained in the list represent in your program
v. Explains how the selected list manages complexity in your program code by explaining why your program code could not be written, or how it would be written differently, if you did not use the list
?
?
First code segment:
word.push(encryptedResult);
Second code segment:
println(word[1]);
The code uses the list word. The list stores the two words that are used by the program. The first entry in the list is the unencrypted word and the second entry is the encrypted word.
The list helps manage complexity because it allows both the un-encrypted word and the encrypted word to be stored in a single variable that is accessible in both the main program to print the results and the function to encrypt the word. If the program did not use a list, it would be more complicated because the values would have to be passed back and forth with the function.
3C.
Provide a written response that does all three of the following:
i. Describes two calls to the procedure identified in written response 3c. Each call must pass a different argument(s) that causes a different segment of code in the algorithm to execute.
ii. Describes what condition(s) is being tested by each call to the procedure
iii. Identifies the result of each call
Capture and paste two program code segments you developed during the administration of this task that contain a student-developed procedure that implements an algorithm used in your program and a call to that procedure.
i. The first program code segment must be a student-developed procedure that:
• Defines the procedure’s name and return type (if necessary)
• Contains and uses one or more parameters that have an effect on the functionality of the procedure
• Implements an algorithm that includes sequencing, selection, and iteration
ii. The second program code segment must show where your student-developed procedure is being called in your program.
Then, provide a written response that does both of the following:
iii. Describes in general what the identified procedure does and how it contributes to the overall functionality of the program
iv. Explains in detailed steps how the algorithm implemented in the identified procedure works. Your explanation must be detailed enough for someone else to recreate it.
First code segment:
function encrypt(key) { var encryptedResult = ""; for(var i = 0; i < word[0].length; i++) { // Get the character in the original message var originalCharacter = word[0].charAt(i); var alphabeticIndex = ALPHABET.indexOf(originalCharacter); if(alphabeticIndex >= 0) { // Compute new index var newIndex = alphabeticIndex + key; newIndex = newIndex % ALPHABET.length; // Get the new character var newCharacter = ALPHABET.charAt(newIndex); // Add the new shifted character to the encrypted result encryptedResult += newCharacter } // Otherwise we'll keep the original character else { encryptedResult += originalCharacter; } } word.push(encryptedResult); }
Second code segment:
encrypt(shift);
The included function, encrypt, takes an unencrypted word and decrypts it using a Caesar Cipher. This contributes to the overall program execution by performing the encryption on a given word and then storing that word in the word list so that the main program can print out the decrypted word.
The function does this by taking the amount to shift the letters as an input parameter. It then shifts every letter to get the encrypted result.
3D.
The two test cases are based on different shift amounts that are input for the same word. In the first case, Hello was entered and the shift was 5. For this test case, the encrypt function will take each letter and shift it over by 5 places. The result from this was MJQQT. The second call used the word Hello again, but this time shifted the letter 20 places. By shifting the letters 20 places, it causes the letters to wrap around and the results is BYFFI.
Row 1:
The response earned the point for this row, meeting all six criteria:
• The video demonstrates the program receiving user input for both the unencrypted phrase and the shift
• The program's purpose is to encrypt a phrase and the video demonstrates this purpose
• The program demonstrates output by printing out the encrypted phrase
• The input and output is described in the response by stating "In the video, you can see 2 different inputs. The first input is the un-encrypted phrase and the second input is the number of characters to shift the letters. You can also see the program output the encrypted phrase."
Row 2:
The response earned the point for this row, meeting all three criteria:
• Two distinct code segments are shown
• The name of the list is described as word
• The response states what values are stored in the list and how it serves the function of the program here: "it allows both the un-encrypted word and the encrypted word to be stored in a single variable that is accessible in both the main program to print the results and the function to encrypt the word."
Row 3:
The response does not earn the point for this row. Even though the program states how it manages complexity and how it would be different without a list, the use of a list in this scenarios does not actually make the program less complex.
• The response includes a program code segment that shows a list being used; however, the list does not manage complexity in the program, as the same result could be accomplished with two variables.
• Using two variables and/or passing values back and forth between the main program and the function would not make the program any more complex than it currently is.
Row 4:
The response earned the point for this row, meeting both criteria:
• The response includes two distinct code segments, one defining a function encrypt with the key parameter and the other calling this function
• The response describes how the procedure contributes to the program functionality by stating "This contributes to the overall program execution by performing the encryption on a given word and then storing that word in the word list so that the main program can print out the decrypted word."
Row 5:
The response does not earn the point for this row. The selected algorithm includes sequencing, selection, and iteration, however the response does not state how the selection statement is being used. While the code is sufficient to earn the point, the point is not earned because the explanation was not thorough enough.
Row 6:
The response does not earn the point for this row as it does not meet the first requirement:
• Two different calls are described, 5 and 20. For each, the code segment that is executed is described, however the same set of code is run in each case. To earn the point, one of the test needs to run the else cause of the selection statement.
• For each call, the condition being tested is described. "By shifting the letters 20 places, it causes the letters to wrap around..."
• The result of each call is described in the response.