Elementary Programming Principles
Elementary Programming Principles
Human beings have evolved from the Stone Age to a highly sophisticated and advanced
society by inventing things like the wheel, fire, transistors and today’s ultra modem devices
like computers. The idea of computers started way back in the nineteenth century.
The first generation computers called Electronic Numeric integrator and Calculator (ENIAC 1)
were operated by plugging wires into a control panel that resembles the old telephone
switchboards
Computer programming
A computer works by executing a set of instructions known as a program. The
term programming refers to the process of developing computer instructions (programs) used
to solve a particular task. It involves use of special characters, signs and symbols found in a
particular programming language to create computer instructions. A programming language is
a special set of symbols that can be translated into machine-readable form by the computer
when arranged in a particular sequence or order. Each language has a special sequence or
order of writing characters usually referred to as syntax.
It was John von Neumann of Princeton University (USA) who first came up with the
proposition to store programs in the computer memory. Perhaps, this was one of the most
dramatic developments in the computer history. Why? Because not only did the new stored-
program way of computing increase-processing speed but also allowed easy and flexible
methods of editing and updating the program.
Source program
The term source program refers to the program code that the programmer enters in the
program editor window that is not yet translated into machine-readable form. The source
program is usually created using a particular programming language as discussed later.
Object code
The term object code refers to the program code that is in machine-readable. A source code
that is not in machine-readable form must be translated into object code.
Translators
The term translator is used to refer to language processors such as assemblers,
interpreters and compilers that convert the source program into object code.
Assembler
An assembler translates assembly language into machine language that the computer can
understand and execute.
Interpreter
An interpreter translates the source program line-by-line, allowing the CPU to execute one
line before translating the next. The translated line is not stored in the computer memory. It
means that every time the program is needed for execution, it has to be translated. This
method of translating programs was very common in early computers that did not have
enough memory to store the object code as a file that can be executed later
Compiler
A compiler translates the entire source program into object code: The object code file can be
made into a fully executable program by carrying out another process known as linking which
joins the object code to all the other files that are needed for the execution of the program.
After the linking process, an executable file (application file) is generated. This file is stored
on a storage media such as a disk with a name that has a unique
extension (.EXE). Examples of executable files are WINWORD.EXE and PM70.EXE used to
start Microsoft Word and Adobe PageMaker 7.0 respectively.
The difference between the interpreters and compilers are summarised below:
Low-Level languages
Low-level languages are classified as low because the computer can easily understand them
directly or they require little effort to translate into computer understandable form. These
languages are hardware oriented and therefore they are not portable i.e. a program written
for one computer cannot be installed and used on another. Two types of low level languages
are the machine languages and assembly languages.
High-level languages
High-level languages are very close to the human language (English like) and they can be
read and understood even by people who are not experts in programming. There are many
types of high-level languages and each of them was developed to address a particular
problem-solving domain while others came about due to advancement in technology. These
languages are machine independent. This means that a programmer concentrates on
problem solving during a programming session rather than how a machine operates.
High-level languages can be classified into five groups:
1. Third generation languages. (3 GLs)
2. Fourth generation languages. (4 GLs)
3. Fifth generation languages. (5 GLs) 4. Object oriented languages. (OOPs)
4. Web scripting languages.
Line 5: It marks the beginning of the body section. Anything between <BODY> and </BODY>
will be executed and displayed when the webpage starts running.
Line 6: This line will display the text “We are the world” on the screen. The text will be large
i.e. size HI and it will be centred on the screen. The text will also be bolded.
Line 7: It marks the start point of the script. Notice the line LANGUAGE = ‘JavaScript’ which
tells the browser that the script will be written in JavaScript language.
Line 8: The statement Document. Write tells the browser using JavaScript to write whatever
is in the brackets. Notice that in JavaScript, the end of a statement is marked by a semicolon
(;).
Line 9: The word alert displays a message box on the screen with an OK button. Clicking the
button makes the message box to disappear. The text in the brackets appears in the dialog
box.
Line 10: Closes the script.
Line 11: Marks the end of the body and the HTML code.
Practical activity 3.1
1. Open a text editor program on your computer like NotePad or WordPad.I
2. Type the following program exactly the way it is in the editor:
<HTML>
<HEAD><TITLE> This is my first webpage</TITLE></HEAD> <BODY bgcolor = “red” >
<H l><CENTER><B>Hello World</B></CENTER></HI>
</BODY> </HTML>
3. Save your work as webpage.html on the desktop. Make sure that the Save As Type box
reads “All Files” before clicking the save button in order to avoid saving a text file with two
extensions i.e. webpage.html. txt
4. Close your text editor. Notice that your file on the desktop has the icon of the default web
browser installed on your computer. Double click it to view the web page! Figure 3.4 shows
a sample of the display expected when the file is loaded to the browser. If you have a
colour monitor, it should look as below only that it will have black bold text on a red
background!
5. Check your program and change your background to blue, save then click the refresh
button. What happens?
Advantages and disadvantages of low-level and high-level languages
Having looked at the various programming languages, it is important to identify the
advantages and disadvantages associated with each level of programming languages.
Advantages and disadvantages of low level languages
Advantages
1. The CPU understands machine language directly without translation.
2. The processor executes them faster because complex instructions are already broken
down into smaller simpler ones.
3. Low level languages are stable and hardly crash or break down once written.
Disadvantages
1. Low level languages are difficult and cumbersome to use and learn.
2. They require highly trained experts both to develop and maintain programs.
3. Removing errors (debugging) in low level language programs is difficult.
4. Low level programs are machine dependent i.e. they are not transferable from one
hardware or software platform to another.
Hence we say they are not portable.
Advantages and disadvantages of high level languages
Advantages
1. High level languages are portable i.e. they are transferable from one computer to another.
2. High level languages are user friendly and easy to use and learn.
3. High level languages are more flexible; hence they enhance the creativity of the
programmer and increase productivity in the workplace.
4. High level languages are far much easier to correct errors (debug).
Disadvantages
1. Their nature encourages use of many instructions in a word or statement hence the
complexity of these instructions causes slower program processing.
2. They have to be interpreted or compiled to machine readable form before the computer
can execute them.
(Review questions 3.1)
1. Define the term computer program.
2. What is programming?
3. State three advantages of high level languages over low level, languages.
4. List four examples of high level languages and for each state its most appropriate
application area.
5. Why is an executable file unique as compared to any other file?
6. Differentiate between a compiler and an interpreter. Why did early computers work well
with interpreters?
7. List the various examples of programming languages per generation.
8. State one advantage of machine language over all the other languages.
9. Write the following in full:
(a) HTML (b) OOP
10. Distinguish between source program and object code in programming.
11. Define the term encapsulation as used in object oriented programming. Program
development
The process of program development is not an easy task. Remember that in our definition of
programming, we said that the program must solve a particular problem or accomplish a task.
Hence, before developing a program, the requirements of the eventual users and its
expected functions should be fully understood.
Program development can be broken into the following stages:
1. Problem recognition.
2. Problem definition.
3. Program design.
4. Program coding.
5. Program testing and debugging.
6. Implementation and maintenance.
The completion of one stage leads to the beginning of the next. At the same time, some
stages have to be continuously reviewed in light of the step just before them to make sure
that they meet the requirements. For example, after coding, the code has to be compared to
the design to see whether it meets the design specification. Therefore, this method becomes
very expensive if the correct requirements are not identified at each stage before the next is
initiated.
It is important to note that although some people consider documentation as an independent
stage, it is done at all stages of the program development lifecycle as shown in Figure 3.5.
This is important so that the facts are recorded when they are still fresh and in the required
detail by the programmer.
Problem recognition
Problem recognition refers to the understanding and interpretation of a particular problem. In
order to understand a problem you need to look for the key words such as compute,
evaluate, compare etc. You can then rewrite the problem in a more simplified way using the
keywords.
A programmer identifies problems in the environment and seeks to solve them by writing a
computer program that would provide the solution. Many of the privileges of automation that
we enjoy today are as a result of people who wrote computer programs to do the tasks. For
example, the intelligent control of traffic lights, the autopilot in aircraft and the use of robots in
industry are good examples where problems were recognised and the computer was used as
a tool to solve them. Think of the person who after seeing the tedious nature of typing using a
manual typewriter decided to develop a word processor program!
In any given circumstance, the following three situations can cause the programmer to
identify a problem that is worth solving:
1. Problems or undesirable situations that prevent an individual or organisations from
achieving their purpose.
2. Opportunity to improve the current program. It can be argued that any unexploited
opportunity is a problem.
3. A new directive given by the management requiring a change in the status quo.
Sample problem
Consider a mathematical problem such as calculating the area of a circle. In this case, the
problem is finding the area of a circle. As a programmer, it will be your interest to develop a
program that can be used to calculate the area of any circle. The equation for calculating the
area of a circle is given by A = лr2.
Problem definition
In problem definition, also referred to as problem analysis, the programmer tries to determine
or define the likely input, processing activities and the expected output using the keywords
outlined at the problem recognition stage.
At the end of this stage, the boundaries of the expected program will have been established
i.e. a clear view of what the program needs to accomplish must be in place. In case, several
methods are identified that can be used to solve the same problem, then the best alternative
should be chosen.
In our problem of calculating the area of a circle, an investigation reveals that the parameters
needed to determine the area of any circle are:
1. Input: (a) Pie (л) which is a constant.
(b) The radius of the circle.
2. Process: The formula of calculating area of a circle which is л x radius x radius.
3. Output: The area of the circle (A).
The problem definition stage ends with the writing of a requirements report or document for
the new program. It is this document that enables a programmer to come up with a program
design that meets the needs at hand.
Program design
Program design is the actual development of the program’s processing or problem solving
logic called the algorithm. An algorithm refers to a limited number of logical steps that a
program follows in order to solve a problem. It is the programmer who will usually come up
with the algorithm after carefully analysing the requirements specification. Many programs
are not usually made up of one large block of code i.e. they are not monolithic. Instead,
several units called modules work together to form the whole
In modular programming, each module performs a specific task. This approach makes a
program flexible, easier to read and carry out error correction.
The design phase enables the programmer to come up with models of the expected program.
The models show the flow of events and data throughout the entire program from the time
data is input to the time the program gives out expected information. The development of
algorithms is covered later in the chapter. Program coding
Program coding is the actual process of converting a design model into its equivalent
program. This is done by creating the program using a particular programming language. The
end result of this stage is a source program that can be translated into machine readable
form for the computer to execute and solve the target problem. Programs can be written in
many different languages but the general trend in the world today is to use programs that are
easy to learn and understand such as, Pascal, C++, Visual Basic and Java. Below is a
comparison of the same program written in Pascal and C++ used to calculate the area of a
circle.
Going through the two programs, you will realise that they are fairly similar, irregardless of the
language that was used to code them. The table below explains the program codes.
NB: “\n” is a C++ syntax of directing the character to a new line. It is equivalent to PASCAL’s
“In” used in writeln and readln.
Program testing and debugging
After coding, the program has to be tested and the errors detected corrected (debugged).
There are two types of errors (bugs) that can be encountered when testing a program. These
are:
1. Syntax errors: These errors emanate from improper use of language rules e.g. grammar
mistakes, punctuation; improper naming of variables and misspelling of user defined
and reserved words. Reserved words are those words that have a special meaning to the
programming language and should not be used by the programmer for anything else.
These errors are detectable by the translator and must be corrected before the program
runs.
2. Logical errors: They are not detectable by the translator. The program runs but gives wrong
output or halts during execution. Such errors that occur during program execution are
sometimes called runtime or execution errors.
Methods of error detection
There are several methods of testing the program for errors. These include:
1. Desk checking (Dry-run)
It involves going through the program while still on paper before entering it in the program
editor. This helps the programmer to detect the most obvious syntax and logical errors.
2. Using debugging utilities
After entering the program in the program editor, you can run the debugging utilities during
translation to detect syntax errors in order to correct them before execution.
3. Using test data
The programmer carries out trial runs of the new program. At each run, the programmer
enters various data variations and extremes including data with errors to test whether the
system will grind to a halt. For example, if the input required is of numeric type, the
programmer may enter alphabetic characters to see whether the program will grind to a halt
unexpectedly. A good program should not crash due to incorrect data entry but should inform
the user about the anomaly and request for the entry of the correct data.
Implementation and maintenance
Implementation
Implementation refers to the actual delivery and installation of the new program ready for
use. New programs will obviously change the way things are done when implemented hence
the need for review and maintenance.
Review and maintenance
Review and maintenance is important because of the errors that may be encountered after
the program has been implemented or exposed to extensive use. A program may also fail not
because of poor development but also due to poor use. Therefore proper training and post
implementation support of users will always reduce the chances of having them entering
invalid data that can crash the program.
Program documentation
Program documentation is the writing of support materials explaining how the program can
be used by users, installed by operators or modified by other programmers. All stages of
program development should be documented in order to help during future modification of
the program. Documentation can either be internal or external. Internal documentation, is the
written nonexcutable lines (comments) in the source program that help other programmers to
understand the code statements. External documentation refers to reference materials such
as user manuals printed as booklets. User manuals are common examples of external
documentation There are three target groups for any type of documentation:
1. User oriented documentation. These type enables the user to learn how to use the
program as quickly as possible arid with little help from the program developer.
2. Operator oriented documentation. It is meant for computer operators such as the technical
staff. It helps them to install and maintain the program.
3. Programmer oriented documentation. It is a detailed documentation written for skilled
programmers. This documentation provides necessary technical information to help in
future modification of the program. In this type of documentation, all stages of the program
development should be documented because.
There may come a need to revise or modify the program.
Other programmers may think of ways of improving your program.
Development of algorithms
As defined earlier an algorithm can be defined as a limited number of logical steps that a
program follows in order to solve a problem. In most cases, algorithms can be depicted using
a number of tools such as decision tables, decision tree’s, flowcharts and pseudocodes. In
this book, we shall mainly discuss program flowcharts and pseudocodes because they are
the most widely used by programmers.
Pseudocode
As mentioned earlier, a pseudocode is a set of statements written in a readable language
(usually English-like phrases) but expressing the processing logic of a program. Some of the
words used in a pseudocode may be drawn directly from a programming language and then
mixed with English to form structured statements that are easily understood by non-
programmers and also make a lot of sense to programmers. However pseudocodes are not
executable by a computer.
Guidelines for designing a good pseudocode
1. The statements must be short, clear and readable
2. The statements must not have more than one meaning i.e. should be unambiguous
3. The pseudocode lines should be clearly outlined and indented clearly.
4. A pseudocode should show clearly the start and stop of executable statements and the
control structures (to be discussed later in the section).
5. The input, output and processing statements should be clearly stated, using keywords
such as PRINT, READ, INPUT etc. Below are some examples that demonstrate how to
write a pseudocode. Example 3.1
Write a pseudocode that can be used to prompt the user to enter two numbers, calculate the
sum and average of the two numbers and then display the output on the screen.
Solution
START
PRINT “Enter two numbers”
INPUT X, Y
SUM = X + Y
AVERAGE = SUM/2
PRINT SUM
PRINT AVERAGE
STOP
Example 3.2
Write a structured algorithm that would prompt the user to enter the length and width of a
rectangle, calculate the area and perimeter then display the result.
Solution
First draw the rectangle of length (L) and width (W)
Write down the pseudocode
START
PRINT “Enter length and width”:
READ L, W
AREA = L * W
PERIMETER = 2(L + W)
PRINT AREA
PRINT PERIMETER
STOP
Example 3.3
Write a pseudocode for a program that can be used to classify people according to age. If a
person is more than 20 years; output “Adult” else output “Young person”
Solution
START
PRINT “Enter the age” INPUT AGE
IF AGE> 20 THEN
PRINT “Adult”
ELSE
PRINT “Young person”
Program flowcharts
Unlike a pseudocode which expresses ideas in form of short statements, a flowchart does the
same using both statements and special symbols that have specific meaning. Therefore, a
flowchart is a diagrammatic representation of a program’s algorithm. The symbols are
combined with short text clues which are a form of shorthand understood by programmers.
The special symbols used to draw program flowcharts vary but the most common ones are
as outlined below:
3. Rectangle: Indicates that a processing or data transformation is taking place. For example
SUM=A+B.
4. Rhombus: Used to specify a condition. A condition must evaluate to a boolean value (True
or false) for the program to execute the next instructions.
5. Connector: Used as a connecting point or interface for arrows coming from different
directions.
IF … THEN… ELSE
IF … THEN… ELSE selection is suitable when there are two available options. For example,
in a football match, if a player does a mistake which is considered serious by the rules of the
game, he/she is given a red card. Otherwise, he/she is given a yellow card. The algorithms
below illustrates this situation using the IF … THEN… ELSE selection.
Nested IF selection
Nested IF selection is used where two or more options have to be considered to make a
selection. For example, in an Olympics track event, medals are awarded only to the first three
athletes as follows:
Position Gold medal
Position 2: Silver medal
Position 3: Bronze medal
The pseudocode segment and flowchart extract below shows the structure of the Nested IF
selection.
Pseudocode segment
IF position = 1 THEN medal = “Gold”
ELSE
IF position = 2 THEN medal = “silver”
ELSE
IF position = 3 THEN medal = “bronze’ ELSE
medal = “nil”
END IF
ENDIF
ENDIF
Flowchart extract
The general format of the Nested IF is
IF < condition> THEN statements
ELSE
IF < condition> THEN
statements
ELSE
IF < condition> THEN
statements ELSE
statements
END IF
END IF
ENDIF
CASE Selection
CASE selection is an alternative to the Nested IF especially where there are several options
to choose from. This selection is preferred to the Nested IF in order to reduce the many lines
of code. However, it is important to note that the boolean expression for the case selection
can only be expressed using integers and alphabetic characters only. Generally the boolean
expression should be CASE integer OF or CASE Char OF as illustrated in the example
below. In this case, average must be an integer.
Pseudocode
CASE average OF
80..]00: Grade = ‘A’
70.. 79: Grade = ‘B’
60.. 69: Grade = ‘C’
50.. 59: Grade = ‘D’
40 .. 49: Grade = ‘E’
ELSE
Grade = ‘F’
ENDCASE
Flowchart extract
General format of case
CASE x OF
Label: statement
Label 2: statement 2
Label 3: statement 3
Label n: statement n -1
ELSE
statementn
ENDCASE
Note that the flowchart is not different from that of the Nested IF construct- Iteration (
looping)
Iteration, also referred to a looping or repetition is designed to execute the same block of
code again and again until a certain condition is fulfilled. Iteration is important in situations
where the same operation has to be carried out on a set of data many times. For example,
assume that you are writing a program that will use the same formula to calculate the
average marks of three subjects for each student in a class and that the student records are
stored in a computer file.
To calculate the average score for each student in a class, the program should repeatedly
read record by record from the file, and then use the formula after each read operation to
calculate the average.
Generally, the three main looping controls are:
( a) The WHILE loop
The REPEAT. .. UNTIL loop
The FOR loop
The WHILE loop
The ‘WHILE’ loop is used if a condition has to be met before the statements within the loop
are executed. Therefore, this type of loop allows the statements to be
executed zero or many times. For example in banking, to withdraw money using an
automated teller machine (ATM) a customer must have a balance in his/her account.
This scenario can be represented as follows using an algorithm
Pseudocode segment
WHILE balance> 0 Do Withdraw cash
Flowchart extract Update account
END WHILE
Withdraw cash Update account
In our case above,
1. The condition balance> 0 is first tested.
2. If it is true, the account holder is allowed to withdraw cash.
3. The program exits the loop once the balance falls to zero.
In general, the WHILE loop can be represented using a pseudocode and a flowchart extract
as shown below. Pseudocode segment WHILE < condition> DO
statements
ENDWHILE
The REPEAT … UNTIL loop
Unlike the ‘WHILE’ loop, REPEAT… UNTIL allows the statements within it to be executed at
least once since the condition is tested at the end of the loop. For example, consider the ATM
cash withdrawal case discussed under the ‘WHILE’ loop. If the REPEAT … UNTIL is used,
then the client will be able to withdraw the cash at least once since availability of balance is
tested at the end of the loop as shown below.
Pseudocode
REPEAT Withdraw cash
Update account
UNTIL balance > 0;
The general format of the REPEAT. .. UNTIL loop is;
Pseudocode
REPEAT
statements
UNTIL < condition>
The FOR loop
The FOR loop is used in circumstances where execution of the choosen statements has to
be repeated a predetermined number of times. For I example, consider a program that can
be used to calculate the sum of ten numbers provided by the user. The ‘FOR’ loop can be
used to prompt the user to enter the 10 numbers at most ten times. Once the numbers have
been entered, the program calculates and displays the accumulated sum. The loop is
predetermined because it has to be repeated 10 times as shown by the algorithms below.
Pseudocode
FOR count = 1 to 10 DO PRINT “Enter a number (N)”
INPUT N Sum=Sum+N
END FOR
Display SUM
Explanation
The FOR loop in the problem above functions as follows:
1. The loop variable (count) is first initialised to the lower limit, in this case a value of 1.
2. The lower limit is then tested against the upper limit whose value is set at 10.
3. If the lower limit is less than or equal to 10, the program prompts the user to enter a
number N, otherwise the computer exits the loop.
4. After the last statement in the loop has been executed, the loop variable count is
incremented by a 1 and stored in the lower limit i.e. lower limit = count + 1. 5. The lower
limit is then stored in count and step (2) is repeated
The FOR loop can also be used to count downwards from the upper limit to the lower limit.
For example, in the above problem, the upper limit 10 can be tested against the lower limit 1
as follows.
FOR count = 10 DOWN TO 1 DO
Therefore the general format of the FOR loop can be represented using two sets of
algorithms. 1. Pseudocode for ‘FOR’ loop that counts from the lower limit FOR loop
variable = lower limit To upper limit DO.
statements
ENDFOR
2. Pseudocode for a ‘FOR’ loop that counts from the upper limit down to the lower limit
FOR loop variable = Upper limit DOWN TO Lower limit DO statements;
ENDFOR.
Designing more complex algorithms
The following examples demonstrates how to design more complex algorithms based on
what has been covered previously. This is aimed at helping a beginner programmer
understand how control structures are used to design logically correct algorithms.
Example 3.7
With aid of a pseudocode and a flowchart, design an algorithm that:
Prompt the user to enter two numbers X and Y.
Divide X by Y. However, if the value of Y is 0, the program should display an error message
“Error: Division by zero”.
Solution
Using a pseudocode
START
PRINT “Enter 2 numbers X and Y”
INPUT X, Y
IF Y = 0 THEN
PRINT “Error: Division by zero”
ELSE
Quotient = X/Y
PRINT X, Y, Quotient
ENDIF STOP
Example 3.8
Tusaidiane Savings Society (TSS) pays 5% interest on shares exceeding 100 000 shillings
and 3% on shares that do not meet this target. However no interest is paid on deposits in the
member’s TSS bank account. Design an algorithm for a program that would:
Prompt the user for shares and deposit of a particular member.
Calculate the interest and total savings.
Display the interest and total savings on the screen for a particular member of the society.
Solution
Using a pseudocode
START
PRINT “Enter member name, share and deposit”
INPUT Name, Shares, Deposit
If shares> 100 000 THEN
Interest = 0.05 x shares ELSE
Interest = 0.03 x shares ENDIF
Total savings = Deposit + shares + Interest PRINT Name, Total Saving, Interest
STOP
Example 3.9
In an athletics competition, an athlete is rewarded as follows:
1 st position: Gold
2nd position: Silver
3rd position: Bronze
Draw a flowchart for a program that would be used to determine the type of medal to be
rewarded to each athlete.
Example 3.10
The class teacher of Form 3W in a secondary school requested a programmer to design for
her a simple program that would help her do the following:
Enter the names of students and marks obtained in 8 subjects – Mathematics, English,
Kiswahili, Biology, Chemistry, Business studies, Computer studies and History.
After entering each subject mark, the program should calculate the total and average
marks for each student.
Depending on the average mark obtained, the program should assign grade as follows:
(i) Between 80 and 1 00 – A (ii) Between 70 and 79 – B
Between 60 and 69 – C
Between 50 and 59 – D
Below 50 – E
The program should then display each student’s name, total marks and the average grade.
Using both a flowchart and a pseudocode, write an algorithm that shows the design of the
program.
Solution
Using pseudocode
START
REPEAT
PRINT “Enter name and subject marks”
INPUT Name, Mathematics, English, Kiswahili, Biology, Chemistry, Business, Computer,
History
SUM = Mathematics + English + Kiswahili + Biology + Chemistry +Business + Computer +
History
AVG = SUM/8
IF (AVG <80) AND (AVG<100) THEN
Grade = ‘A’
ELSE
IF (AVG >70) AND (AVG > 79) THEN
Grade = ‘B’
ELSE
IF (AVG >60) AND (AVG >69) THEN
Grade = ‘c’
ELSE
IF (AVG >50) AND (AVG >59) THEN
Grade = ‘D’
ELSE
Grade = ‘E’
ENDIF
ENDIF
ENDIF
ENDIF
PRINT Name, Sum, AVG, Grade UNTIL Count = Number of students STOP.