Computer Programming 12 Lesson 2 - Organizing the Problem By Dan Lunney
Tools for Organizing Problems Problem Analysis Chart Problem Analysis Chart Interactivity or Structure Chart Interactivity or Structure Chart IPO Chart IPO Chart Algorithms Algorithms Flowcharts Flowcharts Internal and External Documentation Internal and External Documentation
Problem Analysis Chart Contains four parts Contains four parts Given data Given data Required results Required results Processing Processing List of solution alternatives List of solution alternatives Comes in the form of a chart Comes in the form of a chart
Problem Analysis Chart (cont.) Given Data Required Result Information we know Information we need to find Processing Solution Alternatives How to determine required information List of ideas for the solution of the problem
Problem Analysis Chart (cont.) Sample problem: Sample problem: Calculate the area of a circle for any given radius Calculate the area of a circle for any given radius
Problem Analysis Chart (cont.) Given Data Required Result Processing Solution Alternatives Pi Radius 1.Set both radius and pi in program 2.Get both radius and pi from user 3.Set pi and get radius 4.Set radius and get pi Area = pi * radius * radius Area of the circle
Interactivity or Structure Chart Organizes the problem into sub- tasks Organizes the problem into sub- tasks Often looks like an organizational chart or web diagram Often looks like an organizational chart or web diagram
Interactivity or Structure Chart (cont.) Control 0000 Module Module Module
Interactivity or Structure Chart (cont.) Area of Circle Control 0000 Read 1000 Calculate 2000 Display 3000
IPO Chart Input/Processing/Output Input/Processing/Output Contains 4 Columns Contains 4 Columns Input Input Processing Processing Module Reference Module Reference Output Output Looks like a chart Looks like a chart
IPO Chart (cont.) InputProcessing Module reference Output All know data from PAC (problem analysis chart) All processes that are required Module number where it takes place Result
IPO Chart (cont.) InputProcessing Module reference Output RadiusPi 1. Enter Radius 2. Get pi value 3. Calculate area 4. Display Area Area
Algorithms An algorithm is a set of step-by- step instructions An algorithm is a set of step-by- step instructions Sometimes called Pseudocode Sometimes called Pseudocode It is the key component to solving any problem It is the key component to solving any problem Cannot assume anything, cannot skip steps, must be executable one step at a time, must be complete Cannot assume anything, cannot skip steps, must be executable one step at a time, must be complete
Algorithms Control module (name of module) Control module (name of module) 1. Instruction 1. Instruction 2. Instruction 2. Instruction 3. Instruction 3. Instruction... Exit Exit
Algorithms Area of Circle Control Module Area of Circle Control Module(0000) 1. Process Read 1. Process Read 2. Process Calculate 2. Process Calculate 3. Process Display 3. Process Display 4. Exit 4. Exit
Algorithms Read Module Read Module(1000) 1. Read radius 1. Read radius 2. Exit 2. Exit
Algorithms Calculate Module Calculate Module(2000) 1. area = pi * radius * radius 1. area = pi * radius * radius 2. Exit 2. Exit
Algorithms Display Module Display Module (3000) (3000) 1. Print area 1. Print area 2. Exit 2. Exit
Flowchart Programmers use algorithms to create flowcharts Programmers use algorithms to create flowcharts Flowcharts are graphic representations of the algorithms Flowcharts are graphic representations of the algorithms Flowcharts have symbols to represent parts of the program Flowcharts have symbols to represent parts of the program Often flowcharts will show errors that may not been seen easily in other organizing charts Often flowcharts will show errors that may not been seen easily in other organizing charts
Flowchart Symbols Data flow line Start/Stop/Exit Process Decision Input/Output Module
Flowchart Example To see a demonstration of how to create a flowchart click the link: To see a demonstration of how to create a flowchart click the link: Sample flowchart video Sample flowchart video Sample flowchart video Sample flowchart video
Flowchart Sample Control Read Calculate Display Exit
Flowchart Sample (cont.) Read Calculate Display Exit Read radius Area = pi * pi * radius Print area
Internal / External Documentation Internal documentation – notes written inside the program for other programmers to read. Lets them know what parts of the program are doing. Internal documentation – notes written inside the program for other programmers to read. Lets them know what parts of the program are doing. External documentation – usually consists of the user manuals for your program so the end user can fully understand how to install and use your program. External documentation – usually consists of the user manuals for your program so the end user can fully understand how to install and use your program.
Sample Problem – Lesson 2 Create a PAC, Structure Chart, IPO Chart, Algorithms, and Flowcharts for the following problem: Create a PAC, Structure Chart, IPO Chart, Algorithms, and Flowcharts for the following problem: Calculate the gross pay for employees based on rate, hours, and overtime hours Calculate the gross pay for employees based on rate, hours, and overtime hours See sample problem sheet See sample problem sheet See sample problem sheet See sample problem sheet