Download presentation
Presentation is loading. Please wait.
Published byBeverly Barker Modified over 9 years ago
1
Introduction to Computing Dr. Nadeem A Khan
2
Lecture 2
3
Read Chapter 3
4
Program Planning 1. Analyze 2. Design 3. Choose the Interface 4. Code 5. Test and Debug 6. Complete the Documentation
5
The Problem-Solving Process Input Processing Output
6
Program Design Tools ► Pseudo-code ► Flow Charts ► Hierarchy Charts
7
Postage stamp problem: How many stamps to put on a envelop given one stamp is needed for every five sheets of paper or a fraction thereof How many stamps to put on a envelop given one stamp is needed for every five sheets of paper or a fraction thereof
8
Pseudocode ► Abbreviated version of actual computer code in English-like statements
9
Pseudo code: Postage Stamp Problem ► Program – Determine the number of stamps for a letter Read Sheets Set the number of stamps to sheets / 5 Round the number of stamps Display the number of stamps
10
Flowcharts ► Special geometric symbols connected by arrows
11
Postage stamp problem Start Read sheets Set stamps = sheets/ 5 Display stamps Round stamps up to next whole number End input processing output processing
12
Elements of Flowcharts Symbol Name Flowline Terminal Input/Output Processing Decision
13
Continued… Symbol Name Connector Off page Connector Predefined process Annotation
14
Hierarchy chart ► Shows overall program structure
15
Hierarchy Charts: Postage Stamp Problem Postage Stamp Problem Read Sheets Calculate stamps Display stamps Set stamps = sheets/5 Round stamps to next whole number
16
Another problem: Given a street number of one-way street in New York, decide the direction of the street, either eastbound or westbound Given a street number of one-way street in New York, decide the direction of the street, either eastbound or westboundNote: Even numbered street: Eastbound Odd numbered street: Westbound
17
Decisions ► Sequence Structure – a sequence followed without skipping any line. ► Decision Structure – a structure which requires a decision for any lines of code to be executed.
18
Decision Structure: Pseudocode IF condition is TRUE THEN Process step(s) 1 ELSE Process step(s) 2 Process step(s) 2 END IF
19
Decision Structure: Flowchart Process Step (s) 2 Is Condition True Process Step (s) 1
20
Decision Structure: Pseudocode What in case of multiple conditions?
21
Decision Structure: Pseudocode IF condition 1 is TRUE THEN Process step(s) 1 ELSE IF condition 2 is TRUE THEN Process step(s) 2 Process step(s) 2ELSE Process step(s) 3 END IF
22
Pseudo-Code: Street Direction Problem Get Street IF Street is EVEN Display Eastbound ELSE Display Westbound END IF
23
Flow Chart: Street Direction Problem End Start Get Street Is street even? Display Westbound Display Eastbound
24
Hierarchy Chart: Street Direction Problem Street Direction Program Get Street Number Decide whether street number is odd or even Display direction
25
Still Another Problem ► Calculate and report the grade-point average of a class.
26
The Loop Structure ► A programming structure that executes instructions many times.
27
Flow chart: loop structure No Process Step(s) Is condition true ? Yes
28
Pseudo code: loop structure ► DO WHILE condition is TRUE Process Step(s) LOOP
29
Draw the Flowchart for the class average problem
30
Pseudo code: Class Average Problem INITIALIZE Counter and Sum to 0 DO WHILE there are more data Get the next Grade Add the Grade to the Sum Increment the Counter LOOP Compute Average = Sum/Counter Display Average
31
Hierarchy Chart: Class Average Problem Class average program Get grade Compute sum Display average Calculate average
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.