teach-ict.com logo

THE education site for computer science and ICT

3. Decompose the problem

The previous page describes the method and the need to keep ordinals in range. Now consider what needs to be done to set out the algorithm. This is called decomposition of the problem

Basic Steps

Step 1: Ask the user if they want to encrypt or decrypt.

Step 2: Ask the user for the key to be used

Step 3: Ask the user for the message

Step 4: Do some validation on the user inputs to ensure that the rest of the program can run properly - for example an empty message is not allowed, or commands that are not encrypt or decrypt. Or a key value that is outside the range 1-26

Step 5: Break down the message into individual characters.

Step 6: If the character is a-z or A-Z, then process it, otherwise leave it unchanged.

Step 7: Encrypt or decrypt as required

Step 8: Present the result.

These stages can now be set out as pseudo-code

 

Challenge see if you can find out one extra fact on this topic that we haven't already told you

Click on this link: What is a symmetric encryption