Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Flowcharting

Similar presentations


Presentation on theme: "Introduction to Flowcharting"— Presentation transcript:

1 Introduction to Flowcharting

2 Objective A program can be divided into 3 parts: Input data
Processing data – Calculation, etc. Output information/results Calculation/ Processing Input Output

3 Arrows From Top to Bottom & from Left to Right Make turn Join together
NOTE: Lines/Arrows must always be horizontal or vertical and never cross to avoid confusion

4 What is a Flowchart? START Display message “How many hours did you work?” Read hours Display message “How much do you get paid per hour?” Read payRate Multiply hours by payRate. Store result in grossPay. Display grossPay END A flowchart is a diagram that depicts the “flow” of a program. A diagram made up of symbols of various shapes connected by arrows. Those symbols indicate either actions to be taken or decisions to be made. It helps us planning & programming. The figure shown here is a flowchart for a pay-calculating program. NOTE: Like IPO charts, there should be nothing programming language specific, just use descriptive words, e.g. “Read” or “Display”

5 Four Flowchart Structures
Sequence (Today) Decision Case Repetition

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

7 Basic Flowchart Symbols
Rounded Rectangle START Display message “How many hours did you work?” Read hours Notice there are three types of symbols in this flowchart: rounded rectangles parallelograms rectangles Each symbol represents a different type of operation. Display message “How much do you get paid per hour?” Parallelogram Read payRate Multiply hours by payRate. Store result in grossPay. Rectangle Display grossPay Rounded Rectangle END

8 Terminals: Rounded Rectangles
START Display message “How many hours did you work?” Terminals represented by rounded rectangles indicate a starting or ending point Only 1 of each allowed! Read hours Display message “How much do you get paid per hour?” Read payRate Multiply hours by payRate. Store result in grossPay. START Display grossPay END Terminal END

9 I/O Operations: Parallelograms
START Display message “How many hours did you work?” Input/Output Operations represented by parallelograms indicate an input or output operation Read hours Display message “How much do you get paid per hour?” Input/Output Operation Read payRate Multiply hours by payRate. Store result in grossPay. Display message “How many hours did you work?” Read hours Display grossPay END

10 Processing: Rectangles
START Display message “How many hours did you work?” Processes represented by rectangles indicates a process such as a mathematical computation or variable assignment (not definition) Read hours Display message “How much do you get paid per hour?” Read payRate Calculate grossPay as hours * payRate Multiply hours by payRate. Store result in grossPay. Process Multiply hours by payRate. Store result in grossPay. Set name to “Fred” Display grossPay END

11 Stepping Through the Flowchart
START Display message “How many hours did you work?” In the next seven slides we will step through each symbol in the flowchart. We will show the program output and the contents of the variables. Read hours Display message “How much do you get paid per hour?” Read payRate Multiply hours by payRate. Store result in grossPay. Variable Contents: hours: ? payRate: ? grossPay: ? Display grossPay END

12 Stepping Through the Flowchart
START Step 1: An Output Operation Display message “How many hours did you work?” Read hours Screen Output How many hours did you work? Display message “How much do you get paid per hour?” Read payRate Multiply hours by payRate. Store result in grossPay. Variable Contents: hours: ? payRate: ? grossPay: ? Display grossPay END

13 Stepping Through the Flowchart
START Display message “How many hours did you work?” Read hours Step 2: An Input Operation (User types 40) How many hours did you work? 40 Display message “How much do you get paid per hour?” Read payRate Multiply hours by payRate. Store result in grossPay. Variable Contents: hours: 40 payRate: ? grossPay: ? The value 40 is stored in hours. Display grossPay END

14 Stepping Through the Flowchart
START Display message “How many hours did you work?” Read hours Screen Output How much do you get paid per hour? Display message “How much do you get paid per hour?” Step 3: An Output Operation Read payRate Multiply hours by payRate. Store result in grossPay. Variable Contents: hours: 40 payRate: ? grossPay: ? Display grossPay END

15 Stepping Through the Flowchart
START Display message “How many hours did you work?” Read hours How much do you get paid per hour? 20 Display message “How much do you get paid per hour?” Read payRate Step 4: Input Operation (User types 20) Multiply hours by payRate. Store result in grossPay. Variable Contents: hours: 40 payRate: 20 grossPay: ? Display grossPay The value 20 is stored in payRate. END

16 Stepping Through the Flowchart
START Display message “How many hours did you work?” Read hours How much do you get paid per hour? 20 Display message “How much do you get paid per hour?” Step 5: The product of hours times payRate is stored in grossPay Read payRate Multiply hours by payRate. Store result in grossPay. Variable Contents: hours: 40 payRate: 20 grossPay: 800 Display grossPay The value 800 is stored in grossPay. END

17 Stepping Through the Flowchart
START Display message “How many hours did you work?” Read hours Screen Output Your gross pay is 800 Display message “How much do you get paid per hour?” Read payRate Multiply hours by payRate. Store result in grossPay. Variable Contents: hours: 40 payRate: 20 grossPay: 800 Display grossPay Step 6: An Output Operation END

18 Connectors Sometimes a flowchart will not fit on one page.
A connector (represented by a small circle) allows you to connect two flowchart segments. A

19 Connectors The “A” connector indicates that the second flowchart segment begins where the first segment ends. If you needed multiple connectors, you would use different letters for each, e.g. “B”, “C” Think of it as a “teleporter” A START END

20 Review What do each of the following symbols represent?
(Answer on next slide)

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

22 Review Name the four flowchart structures. Sequence Decision
Repetition Case (Answer on next slide)


Download ppt "Introduction to Flowcharting"

Similar presentations


Ads by Google