Download presentation
Presentation is loading. Please wait.
1
2.0 Problem Solving PROGRAM DESIGN
Prepared by : Pn Nurul Zakiah Binti IT Department
2
STEP 2: PROGRAM DESIGN Definition: It is a framework or flow that shows the steps in problem solving. Methods to design a program: Pseudocode Flowchart Structure Chart IPO Chart
3
Pseudocode Steps in problem solving that is written half in programming code and half in human language. For example, some part uses C language code and some part uses Malay or English language. Advantages: Easily understood. Easily maintained. The codes are changeable. Disadvantages: Cannot be executed in the computer.
4
Example: START Total=0, Average=0 Input a, b, c Total = a + b + c
Average = Total / 3 Output a, b, c Output Average END
5
Flowchart A graphical representation of data, information and workflow using certain symbols that are connected to flow lines to describe the instructions done in problem solving. It shows the flow of the process from the start to the end of the problem solving.
6
Enter data from keyboard Calculate total Display data and total
Flowchart Explanation Enter data from keyboard Calculate total Display data and total START Input Process Output END
7
Explanation of basic flowchart symbol:
Simbol / Symbol Penerangan / Explanation Indicate the direction of data flow. Used to connect a block to another block. Indicates operations / process involved. Receive / read value Display value Execute decision based on condition. Test is performed and the program flow continues, based on the result. Indicates the beginning and end of a flowchart. Show the continuing flowchart in the same page. Flow Lines Process Input / Output Decision Start / End Flow Lines On-page connector Flow Lines
8
Symbol usage START True Condition True Statement False False statement
Input Condition False statement Output END False True Statement True Symbol usage
9
Cont…Explanation of basic flowchart symbol:
Output END B START Input Process First page Next page Symbol Usage Symbol Explanation Flowchart continues in the next page. Off Page Connector
10
There are few additional symbols of flowchart used in a complicated program: GOSUB and RETURN. It’s usually used in a big program. Symbol Explanation Instruct the executed instruction to move to the next function Instruct the executed instruction to return to the next instruction after the GOSUB instruction, called the function. GOSUB RETURN
11
area =22 / 7 * radius * radius
Output area area RETURN Input radius START END GOSUB area Symbol Usage
12
Example Flowchart: Flowchart to calculate the total of fine for late returning of library books.
START Input total_of_day Fine = total_of_day * 0.20 Output Fine END Symbol Usage
13
Structure Charts Structure chart is an additional method in preparing programs that has many sub modules. It consists rectangular boxes, which represents all the sub modules in a program and is connected by arrows. It illustrates the top-down design of a program and is also known as hierarchical chart because its components are in hierarchical form. The advantage is that it is easy to be drawn and to be changed. Format: MainModule SubModule 2 SubModule 3 SubModule 1 SubModule 2.1 SubModule 2.2
14
Problem: To calculate the amount of water bill
Example 1: Problem: To calculate the amount of water bill Represent the modules in the program Water bill Get / read data Compute the charge Display instructions for user Determine the late charge Display the bill Print the bill
15
Represent the modules in the program Display instructions for user
Example 2: Problem: To calculate area of a circle Represent the modules in the program Area of a circle Get / read data Compute the area Display instructions for user Define the area Display the area Print the area
16
IPO Chart (Input Process Output)
Module Reference No. Output All inputs All Process Module Reference No. from structure chart All outputs
17
Example : Calculate the Salary of Employee
Input Process Module Reference No. Output Hour Pay rate Start Enter hour Enter pay rate Calculate salary Display salary End 0000 1000 2000 3000 Salary 0000
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.