Chapter 3: Selection Structures: Making Decisions

Slides:



Advertisements
Similar presentations
Chapter 4 Decision Making Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition) by S.N. Kamin, D. Mickunas, E. Reingold.
Advertisements

If Statements, Try Catch and Validation. The main statement used in C# for making decisions depending on different conditions is called the If statement.
Chapter 13 Control Structures. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display Control Structures Conditional.
Pascal Programming Today Chapter 4 1 »Conditional statements allow the execution of one of a number of possible operations. »Conditional statements include:
Decisions (Conditional Programming) Chapter 5 (Sec. 5.1 & 5.2)
Chapter 9 IF Statement Bernard Chen. If Statement The main statement used for selecting from alternative actions based on test results It’s the primary.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 4 Decision Structures and Boolean Logic.
Decision Structures and Boolean Logic
Python – Making Decisions Lecture 02. Control Structures A program that only has one flow is useful but limited. We can use if statements to make these.
Flowcharts! January 13, 2005 These are today’s notes! Do you think we will get more snow?
Chapter 4 Selection Structures: Making Decisions.
PAGES:51-59 SECTION: CONTROL1 : DECISIONS Decisions.
Making Decisions Chapter 5.  Thus far we have created classes and performed basic mathematical operations  Consider our ComputeArea.java program to.
1 Boolean Expressions to Make Comparisons Boolean expression –Represents only one of two states –Expression evaluates to either true or false Expressions.
Conditional Statement Chapter 8. Conditional Statements Are statements that check an expression then may or may not execute a statement or group of statement.
Basic Control Structures
CSCI N201: Programming Concepts Copyright ©2005  Department of Computer & Information Science Working with Selection Structures.
Lecture 2 Conditional Statement. chcslonline.org Conditional Statements in PHP Conditional Statements are used for decision making. Different actions.
Java Programming Fifth Edition Chapter 5 Making Decisions.
The If Statement There are no switch statements in Python. You need to use just if statements. There are no switch statements in Python. You need to use.
Silberschatz and Galvin  C Programming Language Decision making in C Kingdom of Saudi Arabia Ministry of Higher Education Al-Majma’ah University.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and.
GCSE COMPUTER SCIENCE Practical Programming using Python Lesson 4 - Selection.
CHAPTER 4 DECISIONS & LOOPS
GCSE COMPUTER SCIENCE Practical Programming using Python
Java Programming Fifth Edition
Repetition Structures Chapter 9
Chapter 4 MATLAB Programming
Decision Making.
Topics The if Statement The if-else Statement Comparing Strings
Using the Priming Read Priming read (or priming input):
Topics The if Statement The if-else Statement Comparing Strings
Boolean Expressions and If statements
IF if (condition) { Process… }
Drawing Conclusions and Making Inferences
Alternate Version of STARTING OUT WITH C++ 4th Edition
Multiple Selections (ELIF Statements)
Control Structures: Selection Statement
Program Flow Control Selection & repetition
Pages:51-59 Section: Control1 : decisions
Three Special Structures – Case, Do While, and Do Until
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Chapter 4: Control Structures I (Selection)
5 × 7 = × 7 = 70 9 × 7 = CONNECTIONS IN 7 × TABLE
5 × 8 = 40 4 × 8 = 32 9 × 8 = CONNECTIONS IN 8 × TABLE
4 × 6 = 24 8 × 6 = 48 7 × 6 = CONNECTIONS IN 6 × TABLE
5 × 6 = 30 2 × 6 = 12 7 × 6 = CONNECTIONS IN 6 × TABLE
Chapter 3: Selection Structures: Making Decisions
Boolean Expressions to Make Comparisons
CHAPTER 4: Conditional Structures
Program Flow.
Selection Structures: Single-alternative
What connections can you make? What else do you notice?
CHAPTER 5: Control Flow Tools (if statement)
Chapter 3: Selection Structures: Making Decisions
Learning Intention I will learn about selection with multiple conditions.
10 × 8 = 80 5 × 8 = 40 6 × 8 = CONNECTIONS IN 8 × TABLE MULTIPLICATION.
3 × 12 = 36 6 × 12 = 72 7 × 12 = CONNECTIONS IN 12 × TABLE
Control Structures: Selection Statement
OPERATORS AND SELECTION 2
Pages:51-59 Section: Control1 : decisions
Variables and Equations
Chapter 3: Selection Structures: Making Decisions
Section 2.5 Solving Equations by Adding or Subtracting
Chapter 3: Selection Structures: Making Decisions
5 × 12 = × 12 = × 12 = CONNECTIONS IN 12 × TABLE MULTIPLICATION.
Solving Linear Equations
5 × 9 = 45 6 × 9 = 54 7 × 9 = CONNECTIONS IN 9 × TABLE
3 × 7 = 21 6 × 7 = 42 7 × 7 = CONNECTIONS IN 7 × TABLE
Control Structures.
Presentation transcript:

Chapter 3: Selection Structures: Making Decisions

3.4 Selecting from Several Alternatives Sometimes, we must handle more than two options in a program. We can use multiple If-Then statements or multiple If-Then-Else statements. If something is true Then Do something Else If something else is true Then Do something else Do a different something else End If

Example If Age >= 18 Then Set Eligibility = “Yes” Else Set Eligibility = “Maybe” Set Eligibility = “No” End If

Hints The number of End If’s must equal the number of If’s. You can draw a line to connect them to check. In the previous example, the check for Age > 15 will never be done if the Age is > 18. Regardless of how many possible conditions are included, only one will ever be executed.

Any Questions ?