SlideShare una empresa de Scribd logo
1 de 14
Making Decisions

    VB.NET



                   1
Objectives
Understand how relational operators are
used to create a condition
Understand and use IF
statements, including nested IF statements
Understand and use compound conditions
Develop and evaluate multiple solutions to
the same problem
Successfully write program solutions that
require decision making
                                             2
Selection Statements
The most common decision structure is the IF statement.
A condition is a boolean expression that evaluates to either
true or false.
Comparison operators require numeric operands and
produce a logical result.
Conditions typically involve one of six relational operators.
 Greater than             >
 Less than                <
 Greater than or equal    >=
 Less than or equal       <=
 Equal                    =
 Not equal                <>

                                                                3
The IF Statement Conditions




                              4
Simple IF Statements (design)


Decision symbol

                     Process symbol




                                      5
Solving the Overtime Problem




                               6
VB.net code Example
Private Sub btnCheck_Click()
        Dim Input, value1, value2 As Integer
        If Input = value1 Then         ‘ Condition 1 is True
                process A                     ‘so only this code runs
        ElseIf Input = value2 Then ‘ Condition 2 is True
                process B                     ‘different response
        Else                           ‘ Neither condition is True
                process C                     ‘can be error message
        End If
End Sub

   Task 1: Create programs to perform the functions shown
   in the flow chart examples.
   Task 2: Create a version(2) of the Correct Change
   program (from Input/Output) using selection statements.

                                                                        7
Nested IF Statements (design)
The term nested IF refers to
an IF statement contained
within the true or false
branch of another IF
statement.




                                8
True OR False Conditions




                           9
Compound Conditions
A compound condition consists of two
conditions within parentheses joined by a
logical operator.
Logical Operators require logical operands
and produce a logical result.
   NOT   Logical opposite
   AND   Both values are true
   OR    At least one value is true
   XOR   Exactly one value is true
                                             10
Logical Operators




                    11
Operator Precedence
When several operations occur in an
expression, each part is evaluated and
resolved in a predetermined order called
operator precedence.
 1st : Evaluate all arithmetic/concatenation
  operators
 2nd : Evaluate all comparison operators
 3rd : Evaluate all logical operators


                                                12
The Select…..Case Statement
When more choices are available use the
Select – Case statement, an example is
shown below.




                                          13
Summary
A condition is an expression that evaluates
to either true or false.
IF statements use conditions to choose
between actions.
The true and false branches of an IF
statement may contain any valid
statement, including other IF statements.
A compound condition is two or more
conditions joined by a logical operator.

                                              14

Más contenido relacionado

La actualidad más candente

If and select statement
If and select statementIf and select statement
If and select statementRahul Sharma
 
Control structures selection
Control structures   selectionControl structures   selection
Control structures selectionOnline
 
Loop control statements
Loop control statementsLoop control statements
Loop control statementsJaya Kumari
 
Operators used in vb.net
Operators used in vb.netOperators used in vb.net
Operators used in vb.netJaya Kumari
 
Shubhrat operator &amp; expression
Shubhrat operator &amp; expressionShubhrat operator &amp; expression
Shubhrat operator &amp; expressionShubhrat Mishra
 
Creating decision structures of a program
Creating decision structures of a programCreating decision structures of a program
Creating decision structures of a programYsa Castillo
 
Type conversion, precedence, associativity in c programming
Type conversion, precedence, associativity in c programmingType conversion, precedence, associativity in c programming
Type conversion, precedence, associativity in c programmingDhrumil Panchal
 
Programming (if else)
Programming (if else)Programming (if else)
Programming (if else)Papon Sarker
 
Control statements in Java
Control statements  in JavaControl statements  in Java
Control statements in JavaJin Castor
 
Introduction to computer programming (C)-CSC1205_Lec5_Flow control
Introduction to computer programming (C)-CSC1205_Lec5_Flow controlIntroduction to computer programming (C)-CSC1205_Lec5_Flow control
Introduction to computer programming (C)-CSC1205_Lec5_Flow controlENGWAU TONNY
 
Type Conversion, Precedence and Associativity
Type Conversion, Precedence and AssociativityType Conversion, Precedence and Associativity
Type Conversion, Precedence and AssociativityAakash Singh
 
Python PCEP Variables
Python PCEP VariablesPython PCEP Variables
Python PCEP VariablesIHTMINSTITUTE
 
Type conversion in c
Type conversion in cType conversion in c
Type conversion in cSHIKHA GAUTAM
 
Control structures in Java
Control structures in JavaControl structures in Java
Control structures in JavaRavi_Kant_Sahu
 
OCA JAVA - 2 Programming with Java Statements
 OCA JAVA - 2 Programming with Java Statements OCA JAVA - 2 Programming with Java Statements
OCA JAVA - 2 Programming with Java StatementsFernando Gil
 
itft-Decision making and branching in java
itft-Decision making and branching in javaitft-Decision making and branching in java
itft-Decision making and branching in javaAtul Sehdev
 

La actualidad más candente (20)

If and select statement
If and select statementIf and select statement
If and select statement
 
Decision control
Decision controlDecision control
Decision control
 
Control structures selection
Control structures   selectionControl structures   selection
Control structures selection
 
Loop control statements
Loop control statementsLoop control statements
Loop control statements
 
C# conditional branching statement
C# conditional branching statementC# conditional branching statement
C# conditional branching statement
 
SDD Conditional Statements
SDD Conditional StatementsSDD Conditional Statements
SDD Conditional Statements
 
Operators used in vb.net
Operators used in vb.netOperators used in vb.net
Operators used in vb.net
 
Shubhrat operator &amp; expression
Shubhrat operator &amp; expressionShubhrat operator &amp; expression
Shubhrat operator &amp; expression
 
Creating decision structures of a program
Creating decision structures of a programCreating decision structures of a program
Creating decision structures of a program
 
Type conversion, precedence, associativity in c programming
Type conversion, precedence, associativity in c programmingType conversion, precedence, associativity in c programming
Type conversion, precedence, associativity in c programming
 
Programming (if else)
Programming (if else)Programming (if else)
Programming (if else)
 
Control statements in Java
Control statements  in JavaControl statements  in Java
Control statements in Java
 
Introduction to computer programming (C)-CSC1205_Lec5_Flow control
Introduction to computer programming (C)-CSC1205_Lec5_Flow controlIntroduction to computer programming (C)-CSC1205_Lec5_Flow control
Introduction to computer programming (C)-CSC1205_Lec5_Flow control
 
Type Conversion, Precedence and Associativity
Type Conversion, Precedence and AssociativityType Conversion, Precedence and Associativity
Type Conversion, Precedence and Associativity
 
Python PCEP Variables
Python PCEP VariablesPython PCEP Variables
Python PCEP Variables
 
Type conversion in c
Type conversion in cType conversion in c
Type conversion in c
 
Control structures in Java
Control structures in JavaControl structures in Java
Control structures in Java
 
OCA JAVA - 2 Programming with Java Statements
 OCA JAVA - 2 Programming with Java Statements OCA JAVA - 2 Programming with Java Statements
OCA JAVA - 2 Programming with Java Statements
 
Conditional statements
Conditional statementsConditional statements
Conditional statements
 
itft-Decision making and branching in java
itft-Decision making and branching in javaitft-Decision making and branching in java
itft-Decision making and branching in java
 

Destacado

Destacado (20)

Data types vbnet
Data types vbnetData types vbnet
Data types vbnet
 
Simple debugging
Simple debuggingSimple debugging
Simple debugging
 
Design for edp
Design for edpDesign for edp
Design for edp
 
Software development lifecycle
Software development lifecycleSoftware development lifecycle
Software development lifecycle
 
Ch 3 event driven programming
Ch 3 event driven programmingCh 3 event driven programming
Ch 3 event driven programming
 
Ndu06 typesof language
Ndu06 typesof languageNdu06 typesof language
Ndu06 typesof language
 
Data structures vb
Data structures vbData structures vb
Data structures vb
 
Design documentation
Design documentationDesign documentation
Design documentation
 
Simple debugging
Simple debuggingSimple debugging
Simple debugging
 
Event driven theory
Event driven theoryEvent driven theory
Event driven theory
 
Data types vbnet
Data types vbnetData types vbnet
Data types vbnet
 
Algorithms
AlgorithmsAlgorithms
Algorithms
 
Event driven programming amazeballs
Event driven programming amazeballsEvent driven programming amazeballs
Event driven programming amazeballs
 
Controls
ControlsControls
Controls
 
Event oriented programming
Event oriented programmingEvent oriented programming
Event oriented programming
 
Using loops
Using loopsUsing loops
Using loops
 
(WRK302) Event-Driven Programming
(WRK302) Event-Driven Programming(WRK302) Event-Driven Programming
(WRK302) Event-Driven Programming
 
Event+driven+programming key+features
Event+driven+programming key+featuresEvent+driven+programming key+features
Event+driven+programming key+features
 
Event driventheory
Event driventheoryEvent driventheory
Event driventheory
 
Writing algorithms
Writing algorithmsWriting algorithms
Writing algorithms
 

Similar a Decisions

Unit IV Array in VB.Net.pptx
Unit IV Array in VB.Net.pptxUnit IV Array in VB.Net.pptx
Unit IV Array in VB.Net.pptxUjwala Junghare
 
Fundamentals of Programming Lecture #1.pptx
Fundamentals of Programming Lecture #1.pptxFundamentals of Programming Lecture #1.pptx
Fundamentals of Programming Lecture #1.pptxEyasu46
 
3 chapter three - part 1.pdf
3 chapter three - part 1.pdf3 chapter three - part 1.pdf
3 chapter three - part 1.pdfAbenezerAsefa1
 
CIS 1403 lab 4 selection
CIS 1403 lab 4 selectionCIS 1403 lab 4 selection
CIS 1403 lab 4 selectionHamad Odhabi
 
Variable, constant, operators and control statement
Variable, constant, operators and control statementVariable, constant, operators and control statement
Variable, constant, operators and control statementEyelean xilef
 
Variable, constant, operators and control statement
Variable, constant, operators and control statementVariable, constant, operators and control statement
Variable, constant, operators and control statementEyelean xilef
 
Introduction To Programming with Python Lecture 2
Introduction To Programming with Python Lecture 2Introduction To Programming with Python Lecture 2
Introduction To Programming with Python Lecture 2Syed Farjad Zia Zaidi
 
Ch5 Selection Statements
Ch5 Selection StatementsCh5 Selection Statements
Ch5 Selection StatementsSzeChingChen
 
Na50 enus devi_14
Na50 enus devi_14Na50 enus devi_14
Na50 enus devi_14thurmond
 
Control structures i
Control structures i Control structures i
Control structures i Ahmad Idrees
 
C UNIT-2 PREPARED Y M V BRAHMANANDA REDDY
C UNIT-2 PREPARED Y M V BRAHMANANDA REDDYC UNIT-2 PREPARED Y M V BRAHMANANDA REDDY
C UNIT-2 PREPARED Y M V BRAHMANANDA REDDYRajeshkumar Reddy
 
Chapter 2 - Flow of Control Part I.pdf
Chapter 2 -  Flow of Control Part I.pdfChapter 2 -  Flow of Control Part I.pdf
Chapter 2 - Flow of Control Part I.pdfKirubelWondwoson1
 
operators and control statements in c language
operators and control statements in c languageoperators and control statements in c language
operators and control statements in c languageshhanks
 
05 Conditional statements
05 Conditional statements05 Conditional statements
05 Conditional statementsmaznabili
 
Xamarin: Branching and Looping
Xamarin: Branching and LoopingXamarin: Branching and Looping
Xamarin: Branching and LoopingEng Teong Cheah
 

Similar a Decisions (20)

Unit IV Array in VB.Net.pptx
Unit IV Array in VB.Net.pptxUnit IV Array in VB.Net.pptx
Unit IV Array in VB.Net.pptx
 
slides03.ppt
slides03.pptslides03.ppt
slides03.ppt
 
C sharp chap4
C sharp chap4C sharp chap4
C sharp chap4
 
Ppt lesson 08
Ppt lesson 08Ppt lesson 08
Ppt lesson 08
 
Fundamentals of Programming Lecture #1.pptx
Fundamentals of Programming Lecture #1.pptxFundamentals of Programming Lecture #1.pptx
Fundamentals of Programming Lecture #1.pptx
 
Operators in java
Operators in javaOperators in java
Operators in java
 
3 chapter three - part 1.pdf
3 chapter three - part 1.pdf3 chapter three - part 1.pdf
3 chapter three - part 1.pdf
 
CIS 1403 lab 4 selection
CIS 1403 lab 4 selectionCIS 1403 lab 4 selection
CIS 1403 lab 4 selection
 
Variable, constant, operators and control statement
Variable, constant, operators and control statementVariable, constant, operators and control statement
Variable, constant, operators and control statement
 
Variable, constant, operators and control statement
Variable, constant, operators and control statementVariable, constant, operators and control statement
Variable, constant, operators and control statement
 
Introduction To Programming with Python Lecture 2
Introduction To Programming with Python Lecture 2Introduction To Programming with Python Lecture 2
Introduction To Programming with Python Lecture 2
 
Ch5 Selection Statements
Ch5 Selection StatementsCh5 Selection Statements
Ch5 Selection Statements
 
MODULE_2_Operators.pptx
MODULE_2_Operators.pptxMODULE_2_Operators.pptx
MODULE_2_Operators.pptx
 
Na50 enus devi_14
Na50 enus devi_14Na50 enus devi_14
Na50 enus devi_14
 
Control structures i
Control structures i Control structures i
Control structures i
 
C UNIT-2 PREPARED Y M V BRAHMANANDA REDDY
C UNIT-2 PREPARED Y M V BRAHMANANDA REDDYC UNIT-2 PREPARED Y M V BRAHMANANDA REDDY
C UNIT-2 PREPARED Y M V BRAHMANANDA REDDY
 
Chapter 2 - Flow of Control Part I.pdf
Chapter 2 -  Flow of Control Part I.pdfChapter 2 -  Flow of Control Part I.pdf
Chapter 2 - Flow of Control Part I.pdf
 
operators and control statements in c language
operators and control statements in c languageoperators and control statements in c language
operators and control statements in c language
 
05 Conditional statements
05 Conditional statements05 Conditional statements
05 Conditional statements
 
Xamarin: Branching and Looping
Xamarin: Branching and LoopingXamarin: Branching and Looping
Xamarin: Branching and Looping
 

Más de nicky_walters

Más de nicky_walters (7)

Pseudocode flowcharts
Pseudocode flowchartsPseudocode flowcharts
Pseudocode flowcharts
 
Data types vbnet
Data types vbnetData types vbnet
Data types vbnet
 
Ndu06 typesof language
Ndu06 typesof languageNdu06 typesof language
Ndu06 typesof language
 
Debugging
DebuggingDebugging
Debugging
 
Decisions
DecisionsDecisions
Decisions
 
Intro to visual studio 2008
Intro to visual studio 2008Intro to visual studio 2008
Intro to visual studio 2008
 
Input output
Input outputInput output
Input output
 

Decisions

  • 1. Making Decisions VB.NET 1
  • 2. Objectives Understand how relational operators are used to create a condition Understand and use IF statements, including nested IF statements Understand and use compound conditions Develop and evaluate multiple solutions to the same problem Successfully write program solutions that require decision making 2
  • 3. Selection Statements The most common decision structure is the IF statement. A condition is a boolean expression that evaluates to either true or false. Comparison operators require numeric operands and produce a logical result. Conditions typically involve one of six relational operators.  Greater than >  Less than <  Greater than or equal >=  Less than or equal <=  Equal =  Not equal <> 3
  • 4. The IF Statement Conditions 4
  • 5. Simple IF Statements (design) Decision symbol Process symbol 5
  • 7. VB.net code Example Private Sub btnCheck_Click() Dim Input, value1, value2 As Integer If Input = value1 Then ‘ Condition 1 is True process A ‘so only this code runs ElseIf Input = value2 Then ‘ Condition 2 is True process B ‘different response Else ‘ Neither condition is True process C ‘can be error message End If End Sub Task 1: Create programs to perform the functions shown in the flow chart examples. Task 2: Create a version(2) of the Correct Change program (from Input/Output) using selection statements. 7
  • 8. Nested IF Statements (design) The term nested IF refers to an IF statement contained within the true or false branch of another IF statement. 8
  • 9. True OR False Conditions 9
  • 10. Compound Conditions A compound condition consists of two conditions within parentheses joined by a logical operator. Logical Operators require logical operands and produce a logical result.  NOT Logical opposite  AND Both values are true  OR At least one value is true  XOR Exactly one value is true 10
  • 12. Operator Precedence When several operations occur in an expression, each part is evaluated and resolved in a predetermined order called operator precedence.  1st : Evaluate all arithmetic/concatenation operators  2nd : Evaluate all comparison operators  3rd : Evaluate all logical operators 12
  • 13. The Select…..Case Statement When more choices are available use the Select – Case statement, an example is shown below. 13
  • 14. Summary A condition is an expression that evaluates to either true or false. IF statements use conditions to choose between actions. The true and false branches of an IF statement may contain any valid statement, including other IF statements. A compound condition is two or more conditions joined by a logical operator. 14