Programming by gyvwpsjkko


									  Information Technology Grade 10                                Teacher Guide

     Series overview
The nine lessons in this series serve as an introduction to programming, and in particular,
object-oriented programming. The difference between procedure-oriented and object-oriented
software development is explained. Although the Java programming language and the jGrasp
Integrated Development Environment is used, concepts that are general to any programming
language are emphasized. The series starts with a lesson that explains the difference between
  E 2+2=4
high-level, assembly and machine languages and the editing, compiling and debugging activities
in program development. The next lessons focus on writing simple programs that include input,
output, G
        variables, assignments and numerical expressions with emphasis on the importance of data
types. Attention is then given to solving a problem by following the software development process of
analysing, designing, implementing and testing a solution. Algorithms are developed and documented
using pseudocode and flowcharts. Test data tables are drawn up and the algorithms are tested using
trace tables. Problems that require selection (if statements) and repetition (while statements) are then
  E 2+2=4
     Curriculum links
The video lessons are designed to address not only the Assessment Standards of the Programming
and Software Development Learning Outcome as given in the National Curriculum Statement, but to
achieve the Learning Outcome itself.
L.O. 4: The learner is able to design, implement, test and deliver efficient and effective solutions to
problem situations.
Assessment Standards
• Produce an algorithm and its correct traces of simple sequential statements involving variables,
  assignments and numeric expressions.
• Design a simple user interface (output and basic input only) for a real activity of an informative
• Draw simple diagrams showing the decision making process involving simple selection and
• Call the basic mathematical functions and apply them in programs.
• Understand that simple data comes in different forms and that data typing is important.
• Implement selection and simple looping in a programming environment for a variety of simple
• Explain effects of rounding and truncation as seen through an application package.
• Use help files effectively for computer application packages.

     Educational approach
Programming is often the most difficult part of the IT syllabus for the learners. Many educators find
it difficult to make the paradigm shift from procedure-oriented to object-oriented programming. To
help both learners and educators, care is taken to use the correct terminology and to introduce the
concepts of object-oriented programming from the start even though the assessment standards
given for the grade 10 syllabus can be achieved using procedure-oriented programming only.
Learners are encouraged to adopt a systematic, structured and disciplined approach to solving
problems using programs by explaining and demonstrating the software development process of
analysis, design, implementation and testing. The lessons include many demonstrations of writing,
compiling, debugging and running complete programs. Each lesson is supported by a worksheet to
be completed by the learners as they watch the videos. Sometimes it will be necessary to pause the
video to allow the learners to complete a segment of the worksheet. These worksheets help to keep
the learner’s attention and serve as notes of the most important concepts. The key to becoming a
proficient programmer is plenty of practice.

Information Technology Grade 10                          Teacher Guide

   Series at a glance

Lesson title                Lesson Outcomes
                            By the end of this lesson, the learner should be able to:

1. Introduction to             E
                            •	 	 xplain the difference between high-level programming
   Programming                 languages, assembly languages and machine language.
                            •	 Identify and describe the tools you would expect to find in an
                               integrated development environment (IDE) for software.

2. Introduction to             E
                            •	 	 dit, compile and run a simple program
   Object-Oriented             R
                            •	 	 ecognize syntax errors
   Programming              •	 Explain the difference between procedure-oriented and object-
                               oriented programming

3. Expressions, Variables   •	 Write valid arithmetic expressions
   and Data Types           •	 Declare variables
                            • Identify data types

4. Creating Objects and        D
                            •	 	 escribe classes and objects
   Reading Input            •	 Distinguish between reference type and primitive type
                            •	 Read input from the standard input stream

5. Working with Numbers     •	 Convert strings to different number data types
                            •	 Format numbers
                            • Use methods from the Math class

6. Designing Algorithms     •	 Design a program as a solution to a problem.
                            •	 Use flowcharts and pseudocode to document algorithms.

7. Using Trace Tables       •	 Use a trace table to test an algorithm
                            •	 Implement a program according to its design.

8. Using Selection          •	 Include decisions in flow charts and in pseudo code
   Structures               •	 Implement decisions in a program

9. Using Repetition         •	 Draw flowcharts that include loops
   Structures               •	 Code loops in Java

  Information Technology Grade 10                                Teacher Guide

 G Teaching guidelines
Lesson 1: Introduction to Programming
In this lesson, the difference between machine-, assembly- and high-level programming languages
is explained as well as the function of tools such as editors, compilers, interpreters and debuggers
in the software development process. We also look at downloading and installing the Java
Development Kit and the jGrasp IDE (Integrated Development Environment). It is expected that the
software would be installed on all the computers in a classroom before classes commence. The
jGrasp IDE and the Java programming language is introduced by compiling and running a small
program, “Greetings”, that simply outputs a message to the console.
The tasks for this lesson require a theoretical understanding of, firstly, the difference between
machine-, assembly- and high-level programming languages and, secondly, of the tools expected in
an Integrated Development Environment (IDE). The second task could be made practical by asking
the learners to identify the tools (or how one accesses them) in the IDE to be used in the classroom.

Lesson 2: Introduction to Object-oriented Programming
The learners write, compile and run the small program introduced in the previous lesson.
Programming style and syntax is introduced. Applets and applications are compared. The main
method of a Java application is introduced. The difference between procedure-oriented and
object-oriented software development is explained. Classes, objects, methods, attributes and method
calls are introduced. Output of text to the standard output stream (console) is explained.
The first task requires the learners to compare the procedure-oriented paradigm with the
object-oriented paradigm by applying both paradigms to a home biscuit baking business. The
learners could be asked to think of their own examples instead. The second task asks for a short
Java program involving only output of text to the console. This task could be replaced or an
additional task could be set that requires some other output to the console, for example a picture
composed of characters.

Lesson 3: Expressions, Variables and Data Types
Expressions consist of operands and operators. The arithmetic operators are addition (+),
subtraction (-) multiplication (*), division (/) and the remainder operator (%) called “mod”. The *, / and
% operators have precedence over + and -. Numbers can be integers or floating-point. Values can
be stored in variables. A variable has a name, a type and a value. A value is given to a variable using
the assignment operator (=) which has the lowest precedence of all operators. A program to convert
Fahrenheit to Celsius, “TemperatureConversion”, is written, and then changed to use variables.
The first task concentrates on the understanding of basic arithmetic expressions in Java. The
task could be extended by adding similar examples. The second task requires writing a program
that includes a simple calculation – the area of a triangle. Although this can be done with just an
expression in an output statement, the learners are required to declare variables for the base, height
and area. This means they must choose appropriate data types. This task could be supplemented by
more programs that require simple calculations and output, but no input.

Lesson 4: Creating Objects and Reading Input
The concepts of classes, objects and attributes and behaviour of objects are explained again using
cell phones as an example. A class diagram is used to document the attributes and behaviours
defined by classes. A state diagram is used to document the values of the attributes of an object at a
particular point in time. A constructor is a special type of method that executes when a new object is
created. Its purpose is to give initial values to the object’s attributes. Reading input from the standard
input stream (keyboard) a line at a time is explained which also necessitates explaining importing

  Information Technology Grade 10                               Teacher Guide

classes from packages and handling exceptions. The program “Greetings” is changed to prompt the
user for input, and then greet the user.
The learners are asked to demonstrate their understanding of the concepts of classes, objects,
attributes and methods and the documentation thereof by drawing class and state diagrams. The
second task requires an understanding of the difference between object variables and primitive type
variables. The third task requires an application of what they have learnt in the lesson about reading
lines of text from the keyboard. This task could be replaced or supplemented by any program that
reads lines of text, without any conversion to numbers, and outputs them in some other order/format.

Lesson 5: Working with Numbers
Code is added to the “TemperatureConversion” program to read input from the keyboard as in
lesson 4, with the necessary adjustment to the prompt. The input is stored in a String variable and
the naming rules and conventions for classes, variables and methods are discussed. Since we can’t
do arithmetic with strings, the input must be converted to an integer using the parseInt method of the
Integer class. This gives rise to a discussion of class (static) methods. The TriangleArea program
(task for lesson 3) is then also converted to be interactive. Floating-point numbers are required as
input and output. Therefore conversion of strings to floating-point numbers (parseDouble method
of the Double class) and the formatting of floating point numbers (using a NumberFormat object)
are discussed. The Java API documentation is used to find out to which package (java.text) the
NumberFormat object belongs. The Java API documentation is further explored to learn about the
Math class including the Math.PI class (static) constant and the Math.round class (static) method.
Since the Math.round method returns a long type value, casting is introduced.
The first task is a paper exercise to ensure that the learners understand the sqrt, pow, abs and round
methods of the Math class. Similar examples could be added. The second task requires a program
that inputs numerical values, performs a simple calculation and displays the result, formatted to have
exactly two decimal places. Any other program that includes input of numbers, simple calculations
and output of the result could be used.

Lesson 6: Designing Algorithms
The software development process introduced in the lesson series on spreadsheets is recapped.
The process is demonstrated by analysing and designing a solution to a problem, the Sponsorship
problem. To design a program solution to a problem, an algorithm must be designed. An algorithm can
be documented using pseudocode and/or a flowchart.
The learners are required to analyse a problem and design a program solution for the problem. This
is a crucial part of software development. It would be of great benefit to the learners to be given more
problems to analyse and design solutions. The problems at this stage should involve only sequential
steps (input, calculations and output), no selection or repetition.

Lesson 7: Using Trace Tables
The demonstration of the software development process from the previous lesson is completed
by testing the algorithm, implementing the program and testing the running program. Test data is
drawn up and the algorithm is tested using a trace table. During the implementation of the program
the requirements are used to write the purpose of the program, the variables in the pseudocode are
identified, data types for the variables are chosen, the variables in the pseudocode are declared,
useful objects are identified, these objects are declared and created, pseudocode is added as
comments and the pseudocode is translated into Java. The test data is used to test the program.

  Information Technology Grade 10                               Teacher Guide

The algorithm designed for the previous lesson’s task must now be tested by drawing up appropri-
ate test data and using trace tables. The program must then be implemented following the guidelines
provided in the lesson and the program tested. If any additional problems were given in the previous
lesson, the algorithms could also be tested and the programs implemented and tested.

Lesson 8: Using Selection Structures
This lesson introduces the selection structure (“if” statement). The café problem (calculating change
or amount owing) is analyzed and a solution for it is designed and tested to illustrate the selection
structure in pseudocode, flowcharts, trace tables and Java code. The comparison operators and their
precedence in relationship to the other operators learnt so far are discussed.
The first task is to implement the program designed for the café problem during the lesson. The code
for the “if” statement is given. The rest of the tasks give practice in representing decision structures
with flowcharts, pseudocode and Java code, and translating one representation to another. It would
be beneficial to the learners to be given additional problems that involve decisions. They should
analyse the problem, design a solution, test the algorithm, implement the program and test the

Lesson 9: Using Repetition Structures
To introduce the repetition structure, a guessing game program is used. The problem is analysed
and the solution program is designed, illustrating repetition structures in flow charts, pseudocode
and trace tables. The implementation of the repetition structure in Java using the “while” statement is
explained. The program must first generate a random number. An object of the Random class is used.
To ensure that never-ending loops are not written, use SITC: Select a variable, Initialize it, Test it at
the beginning of the loop and Change it in the loop.
The first task is once again to implement the program designed during the lesson. For the second
task, a complete Java program is given. The learners must draw a flow chart for the program and then
discover what the program does by using a trace table. This exercise will help the learners understand
the repetition structure. The learners should now be given as many problems as possible to analyse
and subsequently design and implement program solutions. These problems should include input and
output, sequential, selection and repetition structures.


To top