Slides - Chapter 4

Slides - Chapter 4 - Chapter4 MakingDecisions 1 BMGT302...

Info iconThis preview shows pages 1–16. Sign up to view the full content.

View Full Document Right Arrow Icon
Chapter 4 Making Decisions BMGT 302 Business Application  Programming 1
Background image of page 1

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

View Full DocumentRight Arrow Icon
The Selection Structure Selection structure  (or  decision structure ): A decision need to be made based on the outcome of a  condition or comparison Condition Upon which the decision will be made Results in a Boolean (True or False) answer Single-alternative selection structure : performs a  set of tasks only when the condition is true True path : the tasks to perform when the condition is  true 2
Background image of page 2
The Selection Structure (cont’d.) Dual-alternative selection structure :   contains one  set of tasks to perform when the condition is  true  and  a different set of tasks to perform when the condition  is  false False path : the tasks to perform when the condition  is false Pseudocode uses  if…end if  to denote a selection  structure and  else  to denote the false path Indent instructions within the selection structure 3
Background image of page 3

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

View Full DocumentRight Arrow Icon
The Selection Structure (cont'd.) Selection structures you might use today 4
Background image of page 4
The Selection Structure (cont'd.) Selection structures you might use today (cont’d.) 5
Background image of page 5

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

View Full DocumentRight Arrow Icon
Problem specification for Mountain Biking The Selection Structure (cont'd.) Interface for the Mountain Biking application 6
Background image of page 6
The Selection Structure (cont'd.) Pseudocode containing only the sequence structure 7
Background image of page 7

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

View Full DocumentRight Arrow Icon
The Selection Structure (cont'd.) Modified problem specification and pseudocode containing a  single-alternative  selection structure 8
Background image of page 8
Single-alternative selection structure shown in a flowchart Note  the diamond is called decision symbol 9
Background image of page 9

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

View Full DocumentRight Arrow Icon
Modified problem specification and pseudocode containing a  dual-alternativ e selection structure 10
Background image of page 10
Dual-alternative selection structure shown in a flowchart 11
Background image of page 11

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

View Full DocumentRight Arrow Icon
Coding Single-Alternative and Dual- Alternative Selection Structures If…Then…Else statement : used to code single- alternative and dual-alternative selection structures Else clause : an  optional  part of the If statement Only used for the  dual-alternative  selection structure Condition must be a  Boolean expression  that evaluates to  either True or False Can contain variables, literal constants, named constants,  properties, methods, arithmetic operators, comparison operators,  and logical operators  Statement  block : set of statements in the true path  or the false path 12
Background image of page 12
How to use the If…Then…Else statement 13
Background image of page 13

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

View Full DocumentRight Arrow Icon
How to use the If…Then…Else statement (cont’d.) 14
Background image of page 14
Comparison operators  (or  relational operators ): Used as part of the  condition  in an If…Then…Else  statement to compare two values Most commonly used comparison operators: Equal to:  = Greater than:  >
Background image of page 15

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

View Full DocumentRight Arrow Icon
Image of page 16
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/21/2011 for the course BMGT 302 taught by Professor Huang during the Fall '11 term at Maryland.

Page1 / 104

Slides - Chapter 4 - Chapter4 MakingDecisions 1 BMGT302...

This preview shows document pages 1 - 16. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online