CAMBRIDGE LOWER SECONDARY COMPUTING 9: ASSIGNMENT 1.1A Name ___________________________________ Date _____________ Assignment 1.1A: Correct the algorithm This pseudocode algorithm should help a user to decrypt a message. When a letter is encrypted, it is changed to a different character. Using this table here, the ‘p’ is replaced with a question mark (?). If you don't know the code, you cannot read the message. The code used is given in the table. The letter is in the first row and the encrypted character is in the second row. For example, the letter ‘a’ is encrypted as the character ‘0’. a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9 + - = / * ! ? \ # ( ) & % $ @ | OUTPUT "Enter the encrypted character" INPUT character IF character = "0" THEN OUTPUT "a" ELSEIF character = "1" THEN OUTPUT "b" ELSEIF character = "2" THEN OUTPUT "c" ELSEIF character = "3" THEN OUTPUT "d" ELSEIF character = "4" THEN OUTPUT "e" ELSEIF character = "5" THEN OUTPUT "f" ELSEIF character = "6" THEN OUTPUT "g" ELSEIF character = "7" THEN OUTPUT "h" (Continued) 1 CAMBRIDGE LOWER SECONDARY COMPUTING 9: ASSIGNMENT 1.1A ELSEIF character = "8" THEN OUTPUT "i" ELSEIF character = "9" THEN OUTPUT "j" ELSEIF character = "+" THEN OUTPUT "k" ELSEIF character = "-" THEN OUTPUT "l" ELSEIF character = "=" THEN OUTPUT "m" ELSEIF character = " " THEN OUTPUT "n" ELSEIF character = "*" THEN OUTPUT "o" ELSEIF character = "!" THEN OUTPUT "p" ELSEIF character = "?" THEN OUTPUT "q" ELSEIF character = "\" THEN OUTPUT "r" ELSEIF character = "#" THEN OUTPUT "r" ELSEIF character = "(" THEN OUTPUT "t" ELSEIF character = ")" THEN OUTPUT "u" ELSEIF character = "&" THEN OUTPUT "v" ELSEIF character = "%" THEN OUTPUT "w" (Continued) 2 CAMBRIDGE LOWER SECONDARY COMPUTING 9: ASSIGNMENT 1.1A ELSEIF character = "$" THEN OUTPUT "x" ELSEIF character = "|" THEN OUTPUT "y" ELSEIF character = "@" THEN OUTPUT "z" ENDIF Complete the following tasks. 1 Test the algorithm with the encrypted message: #4-42(8*/. Work out using the table what the output should be, and then test it with the algorithm. 2 Find the error(s) in the algorithm and change it so that it works correctly for the message #4-42(8*/. 3 Test the algorithm with the rest of the alphabet one letter at a time. Compare each output to the expected character in the table. If there are any errors, find and correct them. 4 The symbols ? (question mark) and ! (exclamation mark) also need to be encrypted. Select a character to encode each of these and write it in the following table. Make sure neither of the characters you choose have already been used. ? ! 5 Change the algorithm to allow your two selected characters to be entered and the correct symbol (? or !) to be output. 3