Download Concepts of Programming: Problem Solving Techniques and Algorithms and more Thesis Information Technology in PDF only on Docsity! FCS0074 Problem Solving Techniques and Algorithm 1 Chapter 3 Concepts of Programming FCS0074 Problem Solving Techniques and Algorithm 2 Objectives At the end of this topic, students will be able to: • List and describe the six basic tools used to aid in the development of a solution to a problem. • Use a problem analysis chart to consolidate data for a problem. • Use an interactivity chart to designate the modules to be used in the solution of a problem. • Use an IPO chart to designate the input, processing, module number, and output for a solution of a problem. • Use algorithms and flowcharts to develop the instructions for each module in the solution of a problem. • Describe the importance of internal and external documentation. FCS0074 Problem Solving Techniques and Algorithm 5 Communication with Computers • For a computer to “understand” a message, its system of communication requires instructions governed by specific rules. • If instructions are incorrect, the computer will give an error message, the wrong answer, or no answer at all. • Syntax refers to the rules governing the computer operating system, the language, and the application. • An error is called a bug. • Debugging is the process of finding and correcting a bug. • Many bugs are a result of syntax errors, but some are logic errors. You can find and correct most logic errors during the problem-solving process. FCS0074 Problem Solving Techniques and Algorithm 6 Problem Management Problem Analysis • Certain organizational tools will help you learn to solve problems on the computer. •To analyze a problem and set up the most efficient solution, a programmer organizes the solution by using all or some of these tools. •If not, the solution takes longer to program, and the final program is less efficient, lacks readability, and increases programmer frustration. FCS0074 Problem Solving Techniques and Algorithm 7 Problem Management (cont.) • To organize a solution, the programmer first has to understand and analyze the requirements of the problem. • A good way to analyze a problem is to separate it into four parts, shown in the problem analysis chart (PAC). FCS0074 Problem Solving Techniques and Algorithm 10 Problem Management (cont.) Developing Structure Chart/Interactivity Chart • The next step is to divide the processing into subtasks called modules. • Then connect these modules together to show the interaction of processing between the modules. • Each module should contain the tasks to accomplish one function. •There will be one module that controls the flow to most of other modules. This module is called the Control or Main module. FCS0074 Problem Solving Techniques and Algorithm 11 Problem Management (cont.) • Each module should contain not more than 20 instructions. • This breakdown enables you to view a complex program in simpler parts, and to program smaller, simpler parts of a program. • The chart used is called interactivity chart or structure chart. FCS0074 Problem Solving Techniques and Algorithm 12 Problem Management (cont.) • Interactivity Chart FCS0074 Problem Solving Techniques and Algorithm 15 Problem Management (cont.) • Example: The Interactivity Chart for the Payroll Problem FCS0074 Problem Solving Techniques and Algorithm 16 Problem Management (cont.) IPO Chart • the IPO (input-processing-output) chart extends and organizes the information in the problem analysis chart (PAC). • It shows in more detail what data items are input, what processing takes place on the data, and what information will be the end result, the output. • The IPO chart also shows where in the solution the processing takes place. • The output is the first to be completed in an IPO chart. The next is the input, and the last is the processing. FCS0074 Problem Solving Techniques and Algorithm 17 Problem Management (cont.) • The IPO Chart FCS0074 Problem Solving Techniques and Algorithm 20 Problem Management (cont.) • The Form of an Algorithm FCS0074 Problem Solving Techniques and Algorithm 21 Problem Management (cont.) Flowchart • From the algorithms, the programmer develops the flowcharts, the graphic representations of the algorithms. • The algorithms and flowcharts are the final steps in organizing a solution. • There are flowchart symbols for use with various types of processing. • A flowchart shows the flow of the processing from the beginning to the end of a solution. • Each block in a flowchart represents one instruction from an algorithm. Flowchart Symbols
Flowchart Symbol
Explanation
Process Module
Rectangles with lines down each side
indicate the process of modules.They
have one entrance and only one exit.
Counter
A B
Ss
Automatic-Counter Loop
The polygon Indicates a loop with a
counter. The counter starts with A (the
beginning value) and is incremented by S
(the incrementor value) until the counter
is greater than B (the ending value).
Counter is a variable. A, B, and S may
be constants, variables, or expressions.
CO
On-Page Connectors*
Off-Page Connectors*
Flowchart sections can be connected with
two different symbols. The circle connects
sections on the same page, and the home
base plate connects flowcharts from page
to page. Inside these two symbols the
programmer writes letters or numbers. The
on-page connector uses letters inside the
circle to indicate where the adjoining con-
nector is located. An A connects to an A, a
Bto a B, etc. The off-page connectors use
the page number where the next part or the
previous part of the flowchart is located. This:
allows the reader to easily follow the flow-
chart. On- and off-page connectors will have
either an entrance or an exit.
* These connectors should be used as little as possible. They should
be used to enhance readability. Overuse decreases readability and
produces a Cluttered effect.
FCS0074 Problem Solving
Techniques and Algorithm
22
FCS0074 Problem Solving Techniques and Algorithm 25 Example: The Algorithms and Flowcharts for the Payroll Problem (cont.) FCS0074 Problem Solving Techniques and Algorithm 26 Example: Order of Execution of Instructions FCS0074 Problem Solving Techniques and Algorithm 27 Problem Management (cont.) Internal and External Documentation • Internal documentation consists of remarks written with the instructions to explain what is being done in the program. • Internal documentation is written as the program is coded. Good programming techniques require a program to be easily read by another programmer. • External documentation is made up of the manuals or help menus written about the solution. • External documentation is for the user of the program. The end user will use the program to help solve problems.