Flowcharting: Decision Structure

Slides:



Advertisements
Similar presentations
Nested if-else Statements.  Should be indented to make the logic clear.  Nested statement executed only when the branch it is in is executed. For example,
Advertisements

Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 4 Making Decisions in a Program.
Introduction to Flowcharting
Introduction to Flowcharting
Flow Control Analysis & Design Tool: Flowcharts
Introduction to Flowcharting
An Object-Oriented Approach to Programming Logic and Design
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 9 Decisions, Decisions, Decisions.
Introduction to Flowcharting A Supplement to Starting Out with C++, 4th Edition by Tony Gaddis Published by Addison-Wesley.
Computer Programming Rattapoom Waranusast Department of Electrical and Computer Engineering Faculty of Engineering, Naresuan University.
CS 240 Computer Programming 1
Fundamentals of Algorithms MCS - 2 Lecture # 4
Flowcharts So let’s say we want to express the following algorithm to print out the sum of the biggest and smallest of three numbers.
ITEC113 Algorithms and Programming Techniques
Flowchart Diagram Risanuri Hidayat. What A Flow Chart is a sequential diagram that shows the steps involved in an operation or task and the decisions.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 3P. 1Winter Quarter Structured Engineering.
Problem Solving Chapter 2. What is an algorithm? n A solution to a problem that is: –Precise –Effective –Terminating.
(C)opyright 2003 Scott/Jones Publishers Introduction to Flowcharting A Supplement to Starting Out with C++, 4th Edition by Tony Gaddis Scott/Jones Publishers.
CSC103: Introduction to Computer and Programming
Lecturer: Omid Jafarinezhad Sharif University of Technology Department of Computer Engineering 1 Fundamental of Programming (C) Lecture 5 Structured Program.
DCT 1123 Problem Solving & Algorithms
PROGRAMMING, ALGORITHMS AND FLOWCHARTS
CIS Computer Programming Logic
Flow Charting. Goals Create Algorithms using Flow Charting procedures. Distinguish between Flow Charting and Pseudocode. Top-Down Design Bottom-up Design.
Design the program Create a detailed description of program –Use charts or ordinary language (pseudocode) Identify algorithms needed –Algorithm: a step-by-step.
PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.
1 Introduction to Flowcharting. 2 Writing a program Defining the problem –Write down what the program will do Planning –Write down the steps, draw a flowchart.
1 Introduction to Flowcharting. 2 Writing a program Defining the problem –Write down what the program will do Planning –Write down the steps, draw a flowchart.
Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and Elizabeth Drake Chapter 2: Flowcharts.
Flowcharts.
ALGORITHM List of instructions for carrying out some process step by step. A sequence of instructions which has a clear meaning and can performed with.
PROGRAM DEVELOPMENT CYCLE. Problem Statement: Problem Statement help diagnose the situation so that your focus is on the problem, helpful tools at this.
1 Program Planning and Design Important stages before actual program is written.
(C)opyright 2000 Scott/Jones Publishers Introduction to Flowcharting.
Fundamentals of Algorithms MCS - 2 Lecture # 5. Representation of Algorithms (continued) Flowcharts.
1 Introduction to Flowcharting Computer Science Principles ASFA.
FLOWCHARTING AND ALGORITHMS
Pseudocode (pronounced SOO-doh-kohd)  is a detailed yet readable description of what a computer program or algorithm must do, expressed in a formally-styled.
ALGORITHMS AND FLOWCHARTS
Introduction to Flowcharting
Flowchart Symbols Terminal Process Input/ Output Decision
IGCSE 1 Cambridge Algorithms and flowcharts Unit 7 Computer Science
Introduction to Computing
Computer Programming Flowchart.
Introduction to Flowcharting
Introduction To Flowcharting
Numbering System TODAY AND TOMORROW 11th Edition
Introduction to Flowcharting
Flow Charts What are they good for?.
ALGORITHMS AND FLOWCHARTS
Making Decisions in a Program
How to develop a program?
Business Application Development
Structured Program Design
الفصل الثاني الخوارزمية
ALGORITHMS AND FLOWCHARTS
Chapter 2- Visual Basic Schneider
Faculty of Computer Science & Information System
Chapter 2- Visual Basic Schneider
ME 142 Engineering Computation I
Microsoft Visual Basic 2005: Reloaded Second Edition
Introduction to Algorithms - 1
Problem-Solving and Control Structures By Faith Brenner
No Yes START Do you live in Scotland? Take umbrella See last Flowchart
Developing a Program.
Basic Concepts of Algorithm
62 – Sequences and Series Day 1 Calculator Required
Chapter 5: The Selection Structure
Introduction to Flowcharting
Introduction to Flowcharts
Presentation transcript:

Flowcharting: Decision Structure

Review What do each of the following symbols represent? A Terminal Connector Input/Output Operation Process

Review Name the four flowchart structures. Sequence Decision (Today) Case (Today) Repetition

Review: Sequence Structure A series of actions are performed in sequence The pay-calculating example was a sequence flowchart.

Decision Structure One of two possible actions is taken, depending on a condition.

Decision Structure (if-else) A new symbol, the diamond, indicates a yes/no question. If the answer to the question is yes, the flow follows one path. If the answer is no, the flow follows another path YES NO

Decision Structure (if-else) In the flowchart segment below, the question “is x > y?” is asked. If the answer is no, then process A is performed. If the answer is yes, then process B is performed. YES NO is x > y? Process B Process A

Decision Structure(if-else) The flowchart segment below shows how a decision structure is expressed. Flowchart What would this look like in code? if (x>y) { difference = x – y; } else difference = y - x; YES NO Calculate difference as x - y Calculate difference as y - x is x > y?

Decision Structure (if) The flowchart segment below shows a decision structure with only one action to perform. It is expressed with only one process. Flowchart YES NO x > y? Calculate difference as x - y

Case Structure (if-else if) One of several possible actions is taken, depending on the contents of a variable.

Case Structure (if-else if) The structure below indicates actions to perform depending on the value in yearsEmployed. If yearsEmployed == 1 bonus is set to 200 If yearsEmployed == 2, bonus is set to 400 CASE yearsEmployed 1 2 Other SET bonus = 0 SET bonus = 200 SET bonus = 400 SET bonus = 800 If yearsEmployed == 0, bonus is set to 0 If yearsEmployed is any other value, bonus is set to 800

Module - Subprograms A program module (such as a procedure or function) is represented by a special symbol.

Call CalcPay With Input, store result in totalPay Modules START END Read Input. Call CalcPay With Input, store result in totalPay Display “Total Pay: “ + totalPay The position of the module symbol indicates the point the module is executed. A separate flowchart MUST be constructed for the module. The module flowchart will have the subprogram name in the START terminal instead of START

Review What do each of the following symbols represent? Decision Terminal Input/Output Operation Connector Process Module