Flowchart (cont.) 51
VISUAL PROGRAMMING (Session : 2 2022/2023) 12/5/2022
52
Phase 3 : Implementation/Coding
The pseudocode and flow chart which have been done in the design step
will be converted into a program by using certain programming languages
such as BASIC, JAVA, C or C++.
This step solves the problem by enabling the user to start writing the
programs.
VISUAL PROGRAMMING (Session : 2 2022/2023) 12/5/2022
Phase 3 : Implementation/Coding 53
(cont.)
Coding is the actual process of creating a program in a programming
language.
The coded program is referred to as source code.
Must follow certain rules which are called syntax.
Must then be saved as a program which has the extension ‘.cpp’.
To be executed, the program is converted by the computer into object
code using a special program or translator such as a compiler or interpreter.
VISUAL PROGRAMMING (Session : 2 2022/2023) 12/5/2022
54
Phase 4 : Testing/Debugging
The step for checking and verifying the correctness of the program.
The process of making sure a program is free of errors or ‘bugs’ is called
debugging.
Preliminary debugging begins after the program has been entered into the
computer system.
VISUAL PROGRAMMING (Session : 2 2022/2023) 12/5/2022
55
Phase 5 : Maintenance
Last step in the Program Development Life Cycle (PDLC).
Essentially, every program, if it is to last a long time, requires ongoing
maintenance.
A process of updating software for any changes, corrections, additions,
moving to a different computing platform and others so that it continues to
be useful.
A costly process.
Can be very useful especially on extending the life of a program.
VISUAL PROGRAMMING (Session : 2 2022/2023) 12/5/2022
1.4 Problem solving and 12/5/2022
algorithm design
56
VISUAL PROGRAMMING (Session : 2 2022/2023)
Pseudocode (cont.) 57
Sequential Control Structure 12/5/2022
Question:
Calculate the BMI of a user
Solution:
1.0 BEGIN
2.0 DECLARE double bmi, weight, height
3.0 READ weight, height
4.0 CALCULATE bmi = weight / pow (height, 2)
5.0 DISPLAY bmi
6.0 END
VISUAL PROGRAMMING (Session : 2 2022/2023)
Pseudocode (cont.) 58
Sequential Control Structure 12/5/2022
Question:
Find the area of a circle.
Solution:
1.0 BEGIN
2.0 DECLARE double radius, area; const double pi = 3.142;
3.0 READ radius
4.0 CALCULATE area = pi * pow (radius, 2)
5.0 DISPLAY area
6.0 END
VISUAL PROGRAMMING (Session : 2 2022/2023)
Pseudocode (cont.) 59
Sequential Control Structure 12/5/2022
Question:
Calculate the sum of 3 integer and store the value in total.
Solution:
1.0 BEGIN
2.0 DECLARE int no1, no2, no3, total
3.0 READ no1, no2, no3
4.0 CALCULATE total=no1+no2+no3
5.0 DISPLAY total
6.0 END
VISUAL PROGRAMMING (Session : 2 2022/2023)
Pseudocode (cont.) 60
Selection Control Structure 12/5/2022
Question:
Identify whether a number is a positive or negative number
Solution:
1.0 BEGIN
2.0 DECLARE int num
3.0 READ num
4.0 if(num > 0)
4.1 DISPLAY “positive number”
5.0 else
5.1 DISPLAY “negative number”
6.0 END
VISUAL PROGRAMMING (Session : 2 2022/2023)
61
Pseudocode (cont.)
Selection Control Structure
Question: Account Balance Service Charge
Less than RM300 RM5
RM300 or more RM2
Input is account balance.
Process is to identify service charge based on account balance value.
Output is service charge. Write pseudocode and draw flowchart for the task.
VISUAL PROGRAMMING (Session : 2 2022/2023) 12/5/2022
Pseudocode (cont.) 62
Solution: 12/5/2022
1.0 BEGIN
2.0 DECLARE double accountBalance, serviceCharge
3.0 READ accountBalance
4.0 if (accountBalance < 300)
4.1 serviceCharge = 5.00
5.0 else
5.1 serviceCharge = 2.00
6.0 DISPLAY serviceCharge
7.0 END
VISUAL PROGRAMMING (Session : 2 2022/2023)
63
Pseudocode (cont.)
Selection Control Structure
Question:
Design an algorithm that will read two numbers and an integer code from the screen. The value
of the integer code should be 1,2,3 or 4. If the value of the code is 1, compute the sum of the
two numbers. If the code is 2, compute the difference (first minus second). If the code is 3,
compute the product of the two numbers. If the code is 4, and the second number is not zero,
compute the quotient (first divided by second). If the code is not equal to 1,2,3, or 4, display an
error message. The program is then to display the two numbers, the integer code and the
computed result to the screen. 12/5/2022
VISUAL PROGRAMMING (Session : 2 2022/2023)