Selection structures in Jeroo! if, if else, if, else if, else if, else.

Slides:



Advertisements
Similar presentations
1 Chapter Five Selection and Repetition. 2 Objectives How to make decisions using the if statement How to make decisions using the if-else statement How.
Advertisements

Today’s Topics Logical Syntax Logical Syntax o Well-Formed Formulas o Dominant Operator (Main Connective) Putting words into symbols Putting words into.
Flow Control if, while, do-while Juan Marquez (03_flow_control.ppt)
11-May-15 Control Structures part 2. Overview Control structures cause the program to repeat a section of code or choose between different sections of.
SIMPLE PROGRAMS Jeroo – Chapter 4 –. Basic Concepts Jeroo (Java/C++/object-oriented) programing style is case-sensative. Be consistent in coding Logic.
Additional control structures. The if-else statement The if-else statement chooses which of two statements to execute The if-else statement has the form:
true (any other value but zero) false (zero) expression Statement 2
1-1 Expressions and Formulas. Order of Operations ● What is the Order of Operations? It is a set of rules to find the exact value of a numerical expression.
Multiplying Fractions  Step 1:  Look for common terms that can cancel  Step 2:  Look at cancelling signs (if possible)  Step 3:  Multiply the numerator.
5-Oct-15 Introduction and Code. Overview In this presentation we will discuss: What is Jeroo? Where can you get it? The story and syntax of Jeroo How.
Objective 1: To multiply monomials. Objective 2: To divide monomials and simplify expressions with negative exponents.
Using the Order of Operations Mathematicians have established an order of operations to evaluate an expression involving more than one operation. Finally,
CPS120: Introduction to Computer Science Decision Making in Programs.
The Language of Math Punctuation. Punctuation is used in English and other languages to give meaning to what is written. Periods and question marks end.
Chapter 3 Control Flow Ku-Yaw Chang Assistant Professor, Department of Computer Science and Information Engineering Da-Yeh University.
1 Conditions Logical Expressions Selection Control Structures Chapter 5.
16-Oct-15 Loops in Methods And compound conditions.
25-Oct-15 Jeroo Code. Overview In this presentation we will discuss: How to write code in Jeroo How to run a Jeroo program.
Compound inequalities There are 2 types of compound inequalities AND OR.
Order of Operations.
Adding/Subtracting Fractions  Step 1:  Find common denominator  NOTE: If the denominators are the same go to Step 3  Step 2:  Change fractions into.
Addition and Subtraction of Integers In this tutorial, we will learn how to add and subtract signed numbers with the help of a toy car. The line the car.
13-Nov-15 Control Structures. Overview Without control structures, everything happens in sequence, the same way every time Jeroo has two basic control.
PATTERNS CLASS 4 By :Ms.K.Karthika Patterns are things that are arranged following a rule or rule Example: there is a pattern in these numbers: 2, 7,
16-Dec-15 Control Structures VB. Overview Without control structures, everything happens in sequence, the same way every time Jeroo has two basic control.
Selection Hussein Suleman UCT Dept of Computer Science CS115 ~ 2003.
Linear Equations  Know your rules for solving equations  If fractions, multiply through by LCD  Distribute values to parentheses  What you do on one.
CSI 3125, Preliminaries, page 1 Control Statements.
Mile-long hurdle race Suppose that we want to program Karel to run a one-mile long hurdle race, where vertical wall sections represent hurdles. The hurdles.
17-Feb-16 Methods. Overview In this presentation we will discuss these 4 topics: Main method vs. Jeroo methods Choosing behaviors to turn into methods.
CPS120: Introduction to Computer Science Decision Making in Programs.
Inequalities.
1-2 Order of Operations Objective: Use the order of operations to evaluate expressions.
11-Jun-16 Algorithms 2.2. Overview In this presentation we will discuss: What is an algorithm? 5 steps in developing an algorithm A Jeroo example.
LESSON 3 Expressions, Statements, & Operators. STATEMENTS A statement Controls the sequence of execution Evaluates an expression Does nothing (the null.
Methods 9-Mar-17.
Mile-long hurdle race Suppose that we want to program Karel to run a one-mile long hurdle race, where vertical wall sections represent hurdles. The hurdles.
Objective: To solve and graph compound inequalities involving “or”.
Control Structures part 2
Addition and Subtraction of Integers
AND.
Truth Tables for Negation, Conjunction, and Disjunction
Jeroo Code 18-Jul-18.
2.2 Algorithms 21-Jul-18.
Bell Ringer Solve for x: 2(
Exponents.
The C++ IF Statement Part 2 Copyright © Curt Hill
Rational Numbers & Equations
1-1 Expressions and Formulas
Visual Basic – Decision Statements
Introduction and Code 18-Jan-19.
Expressions and Formulas
Conditionals.
1-1 Expressions and Formulas
Control Structures 5-Apr-19.
Nested If Statements While Loops
Using the Order of Operations
The Order of Operations Unit 1 Lesson 3
Chapter 4: Expression and Operator
Control Structures part 2
Using the Order of Operations
1-1 Expressions and Formulas
Warm Up Solve each inequality. 1. x + 3 ≤ x ≤ 7 23 < –2x + 3
Control Structures 12-May-19.
Check your Mandala… You should have the following before you start your final draft: Your completed pre-writing A completed rough draft At least 6 symbols.
2.2 Algorithms 26-Jun-19.
Control Structures VB part 2
Example 7 Investment The future value of $3000 invested for 3 years at rate r, compounded annually, is given by What interest rate will give a future value.
IF 1-Jul-19.
Jeroo Code 7-Sep-19.
Presentation transcript:

selection structures in Jeroo! if, if else, if, else if, else if, else

if else ladder - a multi-way selection Rules: each condition must be in parentheses no semicolon after the parentheses no limit on the number of else if blocks the final else branch is option

if(Louisa.isFlower(AHEAD) { Louisa.hop(); Louisa.pick(); } else if(Louisa.isNet(AHEAD) { LouisA.toss(); } else if(Louisa.isWater(AHEAD) { Louisa.plant(); } else {hop(); turn(RIGHT); }

COMPOUND CONDITIONS OPERATORJEROO SYMBOL MEANING NEGATION!NOT CONJUNCTION&&AND DISJUNCTION||OR

! EXAMPLE !Bob.isNet(AHEAD) //there is not a net ahead.

EXAMPLE Bob.hasFlower() && Bob.isClear(LEFT) //Bob has at least one flower and there is nothing in the cell immediately to the left.

&& EXAMPLE Bob.isFacing(WEST) && (!Bob.isNet(AHEAD) Bob is facing west and there is no net ahead.