{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

01969_PPT_ch02_COMP230

# 01969_PPT_ch02_COMP230 - Programming Logic and Design Fifth...

This preview shows pages 1–13. Sign up to view the full content.

Programming Logic and Design Fifth Edition, Comprehensive Chapter 2 Understanding Structure

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Programming Logic and Design, Fifth Edition, Comprehensive 2 Objectives Learn about the features of unstructured spaghetti code Understand the three basic structures: sequence, selection, and loop Use a priming read Appreciate the need for structure Recognize structure Learn about three special structures: case , do- while , and do-until
Programming Logic and Design, Fifth Edition, Comprehensive 3 Understanding Unstructured Spaghetti Code Spaghetti code : logically snarled program statements Can be the result of poor program design Spaghetti code programs often work, but are difficult to read and maintain Convoluted logic usually requires more code

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Programming Logic and Design, Fifth Edition, Comprehensive 4 Understanding Unstructured Spaghetti Code (continued) Example: College Admissions Admit students who score >= 90 on admissions test if upper 75 percent of high-school graduating class Admit students who score >= 80 on test if upper 50 percent of high-school graduating class Admit students who score >= 70 on admission test if upper 25 percent of high-school graduating class
Programming Logic and Design, Fifth Edition, Comprehensive 5 Understanding Unstructured Spaghetti Code (continued) Figure 2-2 Spaghetti code example

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Programming Logic and Design, Fifth Edition, Comprehensive 6 Understanding the Three Basic Structures Structure : basic unit of programming logic Any program can be constructed from only three basic types of structures Sequence Perform actions in order No branching or skipping any task Selection (decision) Ask a question, take one of two actions Dual-alternative or single-alternative Loop Repeat actions based on answer to a question
Programming Logic and Design, Fifth Edition, Comprehensive 7 Understanding the Three Basic Structures (continued) Sequence structure Figure 2-3 Sequence structure

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Programming Logic and Design, Fifth Edition, Comprehensive 8 Understanding the Three Basic Structures (continued) Selection structure Figure 2-4 Selection structure
Programming Logic and Design, Fifth Edition, Comprehensive 9 Understanding the Three Basic Structures (continued) Dual-alternative if : contains two alternatives if someCondition is true then do oneProcess else do theOtherProcess

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Programming Logic and Design, Fifth Edition, Comprehensive 10 Understanding the Three Basic Structures (continued) Single-alternative if : contains one alternative Figure 2-5 Single-alternative selection structure
Programming Logic and Design, Fifth Edition, Comprehensive 11 Understanding the Three Basic Structures (continued) Single-alternative if Else clause is not required Null case : situation where nothing is done if employee belongs to dentalPlan then deduct \$40 from employeeGrossPay

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Programming Logic and Design, Fifth Edition, Comprehensive 12 Understanding the Three Basic Structures (continued) Loop structure
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}