210 likes | 524 Views
Selection. Choose to perform an action or not perform itChoose to perform an action or otherwise do something elseChoose to perform one of a set of possibilities. Repetition. Do something a fixed number of timesDo something until something becomes trueWhile something is true, do something. Get
E N D
1. Modular flow-charts
2. Selection Choose to perform an action or not perform it
Choose to perform an action or otherwise do something else
Choose to perform one of a set of possibilities
3. Repetition Do something a fixed number of times
Do something until something becomes true
While something is true, do something
4. Getting into detail … Advantages of structure diagrams:
Show overall structure of solution
Clearly identify individual modules (functions?)and relationships between them
Limitations:
Clumsy for showing selection & repetition
Sometimes easier to understand solution as a flow of events and actions than as a structure
5. Modular flowcharts Symbols to show events and actions
All symbols connected by lines
Lines show allowable actions at any point
Modular flowcharts have only one way in and one way out
Modules have only one entranceand one exit point
6. Flowchart symbols
7. Sequence
8. Selection boxes
9. Selection (1)
10. Selection (2)
11. Selection (3)
12. Repetition (1)
13. Repetition (2)
14. Top-down design using flowcharts Modules must have only one entry and one exit point
So “nesting” becomes possible
Helps to identify functions
And so on
15. Nesting of top-down design
16. Example 1
17. Example 2
18. Example 3
19. Exam marks example We have the marks from sixty students who have sat an exam.
We want to know how many students have passed and how many have failed
The pass mark is 50%
20. Example to work out A survey has been carried out to count the number of vehicles crossing the Tay Bridge.The number of cars crossing during each hour is recorded, giving 24 counts per day.
Draw a modular flowchart for a program which reads the counts for one day and produces an output giving the total number of vehicles crossing during the day and the maximum number crossing in one hour.
If time, calculate total income for the day (each vehicle pays 80p) and average vehicles per hour
Can you identify candidates for separate functions?
21. Summary - modular flowcharts Good way to show flow of program,especially selection and repetition
Because only one entrance and exit allowed, very good for representing stepwise refinement
Helps to identify functions
Good for checking correctness of solutions