ITK 168 Decisions Dr. Doug Twitchell September 20, 2005.

Slides:



Advertisements
Similar presentations
Decision Structures - If / Else If / Else. Decisions Often we need to make decisions based on information that we receive. Often we need to make decisions.
Advertisements

Selection Statements Make a decision based on conditions Allows the computer to be intelligent.
Karel – Making More Complex Decisions IF / THEN / ELSE IF THEN BEGIN Instructions END ELSE BEGIN Instructions END Do these when test = False Do these when.
ROBOTC for CORTEX While Loops Part 1
IF statement (i) Single statement. IF ( logical expression ) statement Example: read(*,*) a if (a. lt. 0) a = -a write(*,*) a Or read(*,*) a if (a < 0)
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 4 Making Decisions in a Program.
Decision Structures Chapter 4. Chapter 4 Objectives To understand: o What values can be stored in a Boolean variable o What sequence structures are and.
Lesson 5 - Decision Structure By: Dan Lunney
Programming: Simple Control Structures Part 1 – Conditional Execution Alice.
IDL Tutorials: Day 4 Goal: Learn some programming techniques: Relational operators, conditional statements, boolean operators, loops Angela Des Jardins.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
Chapter 6 Horstmann Programs that make decisions: the IF command.
© Janice Regan, CMPT 102, Sept CMPT 102 Introduction to Scientific Computer Programming Logical and Relational Expressions Nested if statements.
1 Lecture 7:Control Structures I (Selection) Introduction to Computer Science Spring 2006.
Boolean Expressions and If Flow of Control / Conditional Statements The if Statement Logical Operators The else Clause Block statements Nested if statements.
Unit 5 – “Watch Out!”. Introduction New Topics Case Structures New Functions Less? Comparison Function Ultrasonic Sensor.
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.
Decision Structures Chapter 4 Part 2. Chapter 4 Objectives To understand o What relational operators are and how they are used o Boolean logic o Testing.
PAGES:51-59 SECTION: CONTROL1 : DECISIONS Decisions.
1. We’ve learned that our programs are read by the compiler in order, from top to bottom, just as they are written The order of statement execution is.
1 COMS 261 Computer Science I Title: C++ Fundamentals Date: September 21, 2005 Lecture Number: 10.
If…else statements. Boolean Expressions Boolean expression - An expression whose value is either true or false true = 1 false = 0 Datatype: boolean.
Decisions  Relational operators  Operate on two numbers or two Strings  ==, !=, >, >=,
IDL Tutorials: Day 4 Goal: Learn some programming techniques: Relational operators, conditional statements, boolean operators, loops Maria Kazachenko
Copyright © 2012 Pearson Education, Inc. Chapter 4: Making Decisions.
Conditionals-part21 Conditionals – part 2 Barb Ericson Georgia Institute of Technology Nov 2009.
ITEC 109 Lecture 11 While loops. while loops Review Choices –1 st –2 nd to ?th –Last What happens if you only use ifs? Can you have just an else by itself?
While and If-Else Loops ROBOTC Software. While Loops While loop is a structure within ROBOTC Allows a section of code to be repeated as long as a certain.
Basic Conditions. Challenge: ● Ask the user his/her name ● If it’s “Wally,” jeer him ● Pause video and try on your own.
COMP 110 Branching Statements and Boolean Expressions Luv Kohli September 8, 2008 MWF 2-2:50 pm Sitterson
Lesson thirteen Conditional Statement "if- else" ©
Mindstorm NXT-G Introduction Towson University Robotics.
1 st Semester Module3 Condition Statement อภิรักษ์ จันทร์สร้าง Aphirak Jansang Computer Engineering.
Control Flow (Python) Dr. José M. Reyes Álamo. 2 Control Flow Sequential statements Decision statements Repetition statements (loops)
CS 139 – Programming Fundamentals Lecture 08A. Relational/comparison Operators Relational Operator Meaning > is greater than < is less than >= is greater.
Control Flow (Python) Dr. José M. Reyes Álamo. 2 Control Flow Sequential statements Decision statements Repetition statements (loops)
Silberschatz and Galvin  C Programming Language Decision making in C Kingdom of Saudi Arabia Ministry of Higher Education Al-Majma’ah University.
BIT 115: Introduction To Programming Professor: Dr. Baba Kofi Weusijana Pronounced Bah-bah Co-fee Way-ou-see-jah-nah Call him “Baba” or “Dr. Weusijana”
IF STATEMENTS AND BOOLEAN EXPRESSIONS. BOOLEAN EXPRESSIONS Evaluate to a value of true or false Use relational or equivalence operators Boolean operators.
Decision Making: while loops and Boolean Logic. While Loops A while loop is a structure within ROBOTC which allows a section of code to be repeated as.
Sensor Information: while loops and Boolean Logic.
Computer Science 1000 LOGO II. Boolean Expressions like Excel and Scratch, LOGO supports three Boolean operators less than (
Decision making If.. else statement.
Control Flow (Python) Dr. José M. Reyes Álamo.
Conditional Statements and Control Structure
Chapter 3: Decisions and Loops
Sequence, Selection, Iteration The IF Statement
Chapter 4: Making Decisions.
Operator Precedence Operators Precedence Parentheses () unary
CS 106A, Lecture 2 Programming with Karel
Chapter 4: Control Structures
Simple Control Structures
Microsoft Visual Basic 2005 BASICS
Introduction To Robot Decision Making
Karel the Robot – Making Decisions
While Loops and If-Else Structures
Decision making If statement.
Pages:51-59 Section: Control1 : decisions
IF Statements.
Introduction To Robot Decision Making
Computer Science Core Concepts
Conditional Logic Presentation Name Course Name
An Introduction to Linux
Presented by, Mr. Satish Pise
Seating “chart” Front - Screen rows Back DOOR.
There many situations comes in real life when we need to make some decisions and based on these decisions, we decide what should we do next. Similar situations.
Pages:51-59 Section: Control1 : decisions
If-Statements and If/Else Statements
Presentation transcript:

ITK 168 Decisions Dr. Doug Twitchell September 20, 2005

IF What if I want the robot to pick a thing up if there’s one there, but not pick a thing up if there isn’t?

if if(bob.canPickThing()){ bob.pickThing(); } if( >){ > }

if if(bob.canPickThing()){ bob.pickThing(); } if( >){ > } boolean statement

if if(bob.canPickThing()){ bob.pickThing(); } if( >){ > } boolean statement true or false

if Flowchart

if Can I use this to see if there is a wall in front of me?

if if(bob.frontIsClear()){ bob.move(); } bob.turnLeft(); bob.move(); > if( >){ > } >

if What if I want it to left if the front isn’t clear?

if if(!bob.frontIsClear()){ bob.turnLeft(); } bob.move(); > if( >){ > } >

if Can I check to see if the robot is on a certain street?

if if(bob.getStreet == 1){ bob.move(); } if( >){ > } == equal > greater than < less than >= g.t. or equal <= l.t. or equal != not equal

while what if I want the robot to pick up all of the things in a row

while while(bob.canPickThing()){ bob.pickThing(); bob.move(); } while( >){ > }

while while(bob.canPickThing()){ bob.pickThing(); bob.move } while( >){ > } boolean statement true or false

while Flowchart

while How about moving the robot until it gets to avenue 50?

while while(bob.getAvenue() < 50){ bob.move } while( >){ > }

if…else What about when want to turn right if wall is in front and turn left otherwise?

if…else if(bob.frontIsClear()){ bob.turnLeft(); } else { bob.turnRight(); } bob.move(); if( >){ > } boolean statement true or false

if…else Flowchart

Example How can we change the street cleaning robots to make it work better with if and/or while statements?