Hi I have the following assignment. It includes a function and converts an integer into a character that will be displayed after each integer is processed.
help please! I almost have it, yet something is missing from the code.
**This is my original information:
The organization has developed an algorithm that encodes a string of characters into a series of integers between 0 and 94, inclusive. You have been asked to develop an application that decrypts this series of integers into its corresponding string of characters. The user should enter each integer of the encrypted message one at a time. After each integer is entered, the application should convert (that is, decrypt) the integer to its corresponding character, after which the application should display the string of characters that have already been decrypted. If the user enters a value that is less than zero or greater than 94, the application should terminate input. When the user enters the numbers 39, 79, 79, 68, 0, 55, 79, 82, 75, 1 in order, your application should appear as "Good Work!"
These are the steps:
1. Adding a global variable. Before main, add a definition for a string named message, which will hold the decrypted message. Initialize message to the empty string. Use one line for a comment.
2. Declaring a function prototype. After the variable you defined in Step 3, declare a function prototype for the decryptLetter function, which accepts an int parameter and does not return a value.
3. Defining a local variable, prompting the user for and storing the encrypted letter. Add code in main to define int variable named input, then prompt the user for and store the encrypted letter in that variable.
4. Testing the user input. Insert a while repetition statement that executes while the user input is in the range 0 to 94. This ensures that input terminates when the user enters a sentinel value.
5. Decrypting the input. Inside the while statement, call the decryptLetter function with input as its argument. This function, which you will define in Step 9, will decrypt the letter and append the character to string message.
6. Displaying output and prompting the user for the next input. Inside the while statement, add code to display the string message. Before the closing brace of the while statement, add code to prompt the user for and store the next encrypted letter.
7. Decrypting the input. After main, define the decryptLetter function, which accepts int parameter encryptedLetter. Letters should be decrypted by first adding 32 to the int. This value should then be converted to a char type. [ Note: You can implicitly convert an int to a char by assigning the value of an int to a char variable.] This calculation results in the number 1 decrypting to the character '!' and the number 33 decrypting to the character ' A'. To append the decrypted character to message, use the += operator. For example, message += ' A' appends the character ' A' to the end of message.
8. Save, compile and run the application. Test your application to ensure that it runs correctly by entering the number 39. The letter ' G' should be displayed. Now, input the following numbers 79, 79, 68, 0, 55, 79, 82, 75, 1. If your application has been programmed correctly, the application should now display the message Good Work!.