1 / 17

Chapter 2: Flowcharts

Chapter 2: Flowcharts. Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and Elizabeth Drake. Design the program. Create a detailed description of program Use charts or ordinary language (pseudocode) Identify algorithms needed

lduane
Télécharger la présentation

Chapter 2: Flowcharts

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 2:Flowcharts Extended Prelude to Programming Concepts & Design, 3/e byStewart Venit and Elizabeth Drake

  2. Design the program • Create a detailed description of program • Use charts or ordinary language (pseudocode) • Identify algorithms needed • Algorithm: a step-by-step method to solve a problem or complete a task • Algorithms must be: • Well defined • Well ordered • Must produce some result • Must terminate in a finite time

  3. Modular programming Determine the major tasks that the program must accomplish. Each of these tasks will be a module. Some modules will be complex themselves, and they will be broken into submodules, and those submodules may also be broken into even smaller submodules. This is called top-down design Program Design

  4. Documentation for other programmers • In-program documentation (remarks) • Program maintenance manual • For programming experts to help them fix or enhance code written by other programmers • Design documentation • Written by programmer to explain rationale behind methods and code used • Trade Study documentation • A research tool • An attempt to find the best solution

  5. Structured Programming • A method for designing and coding programs in a systematic, organized manner • It combines the principles of top-down design, modularity and the use of the three accepted control structures of sequence, repetition and selection • Sequence, repetition and selection can be expressed in pseudocode, or with flowcharts

  6. Flowcharts • A tool for programmers to design programs • Describes the flow of a program module’s execution with diagrams • Completely different from hierarchy charts • Connected symbols are used to describesequence, repetition, and selection structures • Some prefer to use flowcharting to learn how to express algorithms, and others prefer to use pseudocode • Many programs are designed with a combination of pseudocode and flowcharts

  7. Flowchart Symbols Wiley text: page 100Auxiliary slideMany in Powerpoint

  8. Control Structures • Sequence –in sequential order. • The simplest of control structures – start at the beginning and continue in sequential order. • Repetition – repeat statements more than once • Also called a loop, it needs a stop condition, i.e, the program will continue to loop until some condition is met. • Selection – selectively execute statements • Called a branch, it requires a condition to determine when to execute statements.

  9. Flowchart for a Sequence START Instructions follow each other sequentially Input sales amount from customer Sale Sequential instructions Computer total amount Sales amount x .06 Print report Sale report Hard Drive Printed Report Sale data Save in file END

  10. Flowchart for a Loop Loop or repetition structure flowchart: Ask a questionAnswer is “Yes” Execute the loop Answer is “NO” Exit the loop Question

  11. Flowchart for a Decision Decision or selection structure flowchart: IF --- THEN --- ELSE CASE statement Question Answer is “NO” (false) Answer is “YES” (true)

  12. Flowchart for a Decision ASK THE QUESTION IF condition THEN instruction1 instruction2 as many instructions as needed as many structures (decision, sequential, looping) as neededELSE instruction1 instruction2 as many instructions as needed as many structures (decision, sequential, looping) as neededENDIFContinuation of the program (instructions and structures) TRUE path if the questions answer is true (YES) IF condition THEN as many instructions as needed as many structures (decision, sequential, looping) as needed ENDIF TRUE path if the questions answer is true (YES) FALSE path if the questions answer is false (NO)

  13. Flowchart for a Decision CONDITIONS A < B (A & B are the same data type (numeric or alphanumeric) X + 5 >= Z (X and Z are numeric data types) E < 5 (E is a numeric data type) F > 10 (F is a numeric data type) IFA < BTHEN instructions/structuresELSEIFX + 5 >= ZTHEN instructions/structuresENDIFENDIF Nesting

  14. start Data is put into HOURS and RATE IFHOURS > 40 PAY= RATE * (40 + 1.5 * (HOURS – 40)) PAY = RATE * HOURS end Flowchart for a Decision Example 1 Somewhere before this decision, data is placed in the variables HOURS and RATEIF HOURS > 40 THEN PAY = RATE * (40 + 1.5 * (HOURS – 40))ELSE PAY = RATE * HOURSENDIF

  15. Nested Decisions (IF – THEN – ELSE) Example 2 ENDIF ENDIF

  16. Example 3 ENDIF Range Check ENDIF ENDIF

  17. Example 4 ENDIF ENDIF ENDIF

More Related