INFORMATION TECHNOLOGY: GRADE 12
TERM 2 Week 6: Practical
TOPIC Problem Solving
AIMS OF LESSON ● Identify what needs to be done when solving a problem
RESOURCES Paper based resources Digital resources
DBE Practical Textbook Unit 1.1 (p. 2 to 6) Links on the WCED ePortal
(Use your school issued textbook for the same content) The e-resources below has the actual URL to the websites
INTRODUCTION Problem solving is an essential skill in Industry 4.0. It is listed as the number one skill in 2020 according to the World Economic
Forum. There are various problem-solving techniques, and most of these techniques have the following four steps for problem
solving incorporated in the techniques. The four steps in problem solving are
1. Understand the problem
2. Devise a solution
3. Carry out the plan (solve)
4. Look back (check and interpret)
CONCEPTS AND SKILLS Problem solving
PRE-KNOWLEDGE String manipulation Loops
ACTIVITIES / ASSESSMENT: The Problem: Caesar cipher
In cryptography, a Caesar cipher is one of the simplest and most widely known encryption techniques. It is a type of substitution cipher in which each letter in the
plaintext is replaced by a letter some fixed number of positions down the alphabet. For example, with a left shift of 3, D would be replaced by A, E would become
B, and so on.
Create a program to decrypt the following sentences with a left shift of 3.
Input data Output data
KHOOR ZRUOG HELLO WORLD
LW LV WKH EHVW VXEMHFW IT IS THE BEST SUBJECT
INFORMATION TECHNOLOGY: GRADE 12
•In this step in is important to read •In this step you need to get •Now it is time to start coding. It •In this step it is time to read the
the problem, and it you still don’t your flow diagram or pseudo is important that you test as problem again. Make sure you
understand the problem, reread the
problem. You may
code ready. It does not need to you code. Don’t add a lot of covered everything the problem
be a complete and perfect flow code without testing it, this asks. Also check that your
Step 3: Carry out the plan
Step 1: Understand the problem –
No coding in this step
Step 2: Devise a solution
Step 4: Look back (check and interpret)
highlight/underline the sections that
are important. diagram or pseudo code – just leads to a lot of time debugging program works with other data
get a step-by-step approach to and then you might run out of than what is supplied. If
•ACTIVITY 1 solve the problem. Try to break time to complete your program. needed, you should correct any
Underline or highlight the important up the problem into smaller, If you have done enough code.
sections in the problem listed: manageable parts to solve. planning, this step should be
Identify data structures, easy.
In cryptography, a Caesar cipher is variables and/or methods to
one of the simplest and most widely
help you solve the problem. •ACTIVITY 4:
known encryption techniques.
It is a type of substitution cipher in Write the code for your
which each letter in the plaintext is •ACTIVITY 3: program. You can either open
replaced by a letter some fixed Create a list of processes that Delphi and complete the
number of positions down the need to be done to solve the program there, or you can write
alphabet. problem. Try to list between 5 out the code. If you write out
For example, with a left shift of 3, D to 7 steps you need to do to the code, remember to test it
would be replaced by A, E would
become B, and so on.
solve the problem. Each one of once you are able to work on
Create a program to decrypt the these steps should be Delphi.
following sentences with a left shift of achievable or you can add more
3. details for a step, by adding
either a sub-list with more
•ACTIVITY 2: details, pseudo code or a flow
Start writing and sketching the diagram, which either you feel
problem as you understand it. It will the most comfortable with
be useful if you write out the using.
alphabet before and after the shift
has been applied.
Tips:
Make sure your code is indented (Ctrl + D) and your name / exam number is added to the top of the program in comments.
Use descriptive variable names and number your code with comments as the question paper is numbered.
This will make it easier for your teacher to mark your work
CONSOLIDATION After you completed this lesson you should be able to Identify key statements in problems and use problem solving tools to create a blue print
to solve any problem
VALUES Problem solving, Creative thinking, Analytical thinking
E-RESOURCES https://en.wikipedia.org/wiki/Caesar_cipher
INFORMATION TECHNOLOGY: GRADE 12
Answers:
ACTIVITY 1: Underline or highlight the important sections in the problem listed:
In cryptography, a Caesar cipher is one of the simplest and most widely known encryption techniques.
It is a type of substitution cipher in which each letter in the plaintext is replaced by a letter some fixed number of positions down the alphabet.
For example, with a left shift of 3, D would be replaced by A, E would become B, and so on.
Create a program to decrypt the following sentences with a left shift of 3.
ACTIVITY 2: Start writing and drawing until the problem as you understand it.
Plain: ABCDEFGHIJKLMNOPQRSTUVWXYZ
Cipher: DEFGHIJKLMNOPQRSTUVWXYZABC
ACTIVITY 3: Create a list of processes that need to be done to solve the problem.
1. Get the input
2. Determine the shift
3. Build a string – alphabet
4. Build a string – encrypted
a. Use the shift to determine where the encrypted string should start
b. Remember to add the first part of the alphabet to the end of the sentence
5. Loop the length of the input sentence
a. Extract each letter of the sentence
b. If the letter exists in the encrypted alphabet – find the corresponding letter in the alphabet string
c. Use this letter to build up the decrypted string
6. Display the decrypted string
ACTIVITY 4: Write the code for your program. You can either open Delphi and complete the program there, or you can write out the code. If you write out the
code, remember to test it once you are able to work on Delphi.
INFORMATION TECHNOLOGY: GRADE 12
procedure TForm1.Button1Click(Sender: TObject);
var sWordToDecrypt, sAlpha, sEncrypt: String;
iShift, I, J: integer;
begin
sWordToDecrypt := 'KHOOR ZRUOG'; // 1. Get the input
iShift := 4; // 2. Determine the shift
sAlpha := 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; // 3. Build a string – alphabet
sEncrypt := ''; // 4. Build a string – encrypted
for I := iShift to length(sAlpha) do // a. Use the shift to determine where the encrypted string
should start
begin
sEncrypt := sEncrypt + sAlpha[I];
end;
for I := 1 to iShift - 1 do // b. Remember to add the first past of the alphabet to the
end // of the sentence
begin
sEncrypt := sEncrypt + sAlpha[I];
end;
for I := 1 to length(sWordToDecrypt) do // 5. Loop the length of the input sentence
begin
for J := 1 to length(sEncrypt) do // a. Extract each letter of the sentence
begin
if sWordToDecrypt[I] = sEncrypt[J] then // b. If the letter exists in the encrypted alphabet –
// find the corresponding letter in the alphabet string
begin
sWordToDecrypt[I] := sAlpha[J]; // c. Use this letter to build up the decrypted string
break;
end;
end;
end;
ShowMessage(sWordToDecrypt); // 6. Display the decrypted string
end;